Reformat Code Options

One of the most useful things for me in DataGrip is the ability to reformat code. I am regularly being handed scripts from other developers who have formatted things their way, and I need a quick and efficient way to quickly reformat their code the way I like it, so that it's easier for me to read.

Some options that I have noticed are missing:

  • New lines for create table expressions. This means enabling options to have new lines for CREATE TABLE expressions, that are not related to wrapping.
  • Removing elements where I have selected not to have them. For example, if I have unticked "Spaces around operators" I would like to remove all spaces around operators. Perhaps these option requires not a tick box, but a drop down box of possible options including "Do nothing". This sort of formatting issue exists for a lot of these options, what I want is the opposite of what the tick means, but unticking it means "Do nothing".
  • Changing case for functions. If I have a function called decode like "decode(message_type, '1', 'type_1', '2', 'type_2')" then I'd like to force the case being upper.
  • Removing unnecessary brackets. This might be a harder one, but I am regularly given SQL statements like this "from ((PRODDTA.F4101 A INNER JOIN PRODDTA.F41021 B ON A.imitm = B.liitm) LEFT OUTER JOIN PRODDTA.F4108 C ON C.iolotn = B.lilotn and C.ioitm = B.liitm and C.iomcu = B.limcu)" where there are a pile of completely unnecessary brackets, which when run through your reformatter makes it come out oddly. Similarly I might get a statement like "(((a+b) + c) - d)" where there are a lot of completely unnecessary brackets which do not aide in understanding it. If these could be removed this would be awesome.

 

In addition to this, your example text in the options window should contain an example for every single option. There were several options which had nothing change when I'd tick or untick the box, which meant I had to guess at what it meant by the name of the option, then write my own example to see if it did anything with it.

Please sign in to leave a comment.