BrightSpots / rcv

Ranked Choice Voting Universal Tabulator
Mozilla Public License 2.0
74 stars 19 forks source link

IntelliJ / JSON whitespace formatting issue #238

Open HEdingfield opened 5 years ago

HEdingfield commented 5 years ago

Continuing our discussion in #232:

OK, yeah, I'm pretty confident that IntelliJ is the culprit for all this nonsense. I looked for a bit and couldn't figure out how to either a) tell it to ignore JSON entirely when it reformats, or b) make its rules identical to what DefaultPrettyPrinter is doing. For now, I'm just going to be careful not to let it touch JSON files. I'll open a separate issue for the more robust solution.

Turns out that IntelliJ has a whole section in the settings for JSON. See Editor > Code Style > JSON. In it, there are options to choose if spaces are added before :, after :, or both, among other things. It seems like, if we all get on the same page here, it should work fine.

I haven't had any of the issues that Louis brought up, so I'm guessing he needs to match my settings, which are the standard GoogleStyle scheme that we all loaded up initially. In the "Spaces" tab, I only have "After comma" and "After ':'" checked, for example.

tarheel commented 5 years ago

Yeah, I already have those same settings, and they don't quite match DefaultPrettyPrinter. Have you actually tried creating and committing a new JSON file?

We can make the colon spacing matching by changing the settings for one or the other... but I'm not sure whether we can fix the other issue I've noticed, which is that DefaultPrettyPrinter puts an open curly brace on the same line that an open square bracket is one, e.g.

"tallyResults" : [ {

I don't think you can make IntelliJ do that, and my initial attempt to make DefaultPrettyPrinter stop doing it didn't quite work the way I wanted.

I'm sure we could make everything consistent if we switched to the Gson library.