bytecode-viewer icon indicating copy to clipboard operation
bytecode-viewer copied to clipboard

Consider adding automatic formatting

Open weisJ opened this issue 2 years ago • 4 comments

While working with the codebase I found the codestyle across files to be quite incosistent. This probably results from no well-defined code style. I think it would be worthwhile to configure a plugin like https://github.com/diffplug/spotless/tree/main/plugin-maven to automatically apply formatting through a maven task. This would also allow to enforce the codestyle through a CI task. Any thoughts?

weisJ avatar Apr 26 '22 19:04 weisJ

I think having formatting handled automatically with maven is a great idea, I'm not sure how to go about setting this up yet but I will definitely look into this!

Konloch avatar Apr 28 '22 20:04 Konloch

My goto way to do this is to specify the formatting using the config file for the eclipse jdt formatter (https://github.com/diffplug/spotless/tree/main/plugin-maven#eclipse-jdt), which you can simply export from eclipse after configuring the formatting to your liking. If you provide the file I could do the maven/CI configuration for you.

weisJ avatar Apr 28 '22 20:04 weisJ

Another possibility would be CheckStyle, but in my experience, it is very limited when it comes to special rules for newlines and so on. A completely other approach would be a editor config file which is even more limited, but configures the auto formatter of most well known editors automatically at least. A hybrid approach using an editor config file and some maven plugin that applies rules specific to java files and so on would be the best I think.

ThexXTURBOXx avatar Apr 29 '22 13:04 ThexXTURBOXx

You’ll have to be careful to configure both such that both config and plugin don’t contradict each other. Notably the eclipse config can be used both with eclipse and IntelliJ (through a plugin). Not sure about Netbeans though.

weisJ avatar Apr 29 '22 14:04 weisJ