rabbit-escape icon indicating copy to clipboard operation
rabbit-escape copied to clipboard

`make format` target that formats all code

Open andybalaam opened this issue 8 years ago • 5 comments

It is possible to run Eclipse's code formatter from the command line*.

* although I think only in a graphical environment

Eclipse's formatter is surprisingly effective and comprehensive - better than IDEA's (for my preferred style anyway) and better than anything else I've seen. If anyone knows better, please let me know because I'd much rather avoid depending on Eclipse.

So, make a Make target that formats all the Java code in the project (including Android code) in our preferred style.

Also, write instructions for IDEA and Android Studio to allow them to use the Eclipse Code Formatter plugin to share the same coding style.

If it didn't require a dependency on Eclipse, but something easier, I'd say it was mandatory to run this before committing, or even during every compile.

andybalaam avatar Mar 05 '16 09:03 andybalaam

Sometimes it's nice to put some extra spaces in to get something to line up.

I guess we need to decide if it's worth trading this in for more uniformity.

colonelfazackerley avatar Mar 05 '16 10:03 colonelfazackerley

Aha. Tags can be used to turn off the formatter in certain regions.

http://stackoverflow.com/questions/5115088/turn-off-eclipse-formatter-for-selected-code-area

colonelfazackerley avatar Mar 05 '16 10:03 colonelfazackerley

Yes, that's the nuclear option, and we can also adjust the format to allow things we like.

andybalaam avatar Mar 05 '16 20:03 andybalaam

Artistic Style looks like it might do what we need.

andybalaam avatar Apr 01 '16 22:04 andybalaam

I am considering starting a small project called Kevlin that runs a code formatter that formats code as Kevlin would have it.

andybalaam avatar Apr 01 '16 22:04 andybalaam