Hi, On Tue, 2019-11-12 at 11:47 +0100, Konrad Windszus wrote: > Hi, > As Angela noticed there is still no official code style guideline for > Sling. Maybe we can at least document the minimum somewhere below > https://sling.apache.org/documentation/development.html < > https://sling.apache.org/documentation/development.html> and provide > an Eclipse Formatter Ruleset. > Such a formatter can not only be applied by Eclipse, but also by > IntelliJ ( > https://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/ > < > https://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/> > ;) and we could even think about optionally applying it with maven ( > https://code.revelc.net/formatter-maven-plugin < > https://code.revelc.net/formatter-maven-plugin>;). > > Also I would recommend to also reference > https://google.github.io/styleguide/javaguide.html < > https://google.github.io/styleguide/javaguide.html> as the Oracle > coding conventions are no longer maintained ( > https://www.oracle.com/technetwork/java/codeconventions-150003.pdf < > https://www.oracle.com/technetwork/java/codeconventions-150003.pdf>;) > . > WDYT?
I think a style guide would work well for us. I am not sure that reformatting whole modules is a worthwhile effort, due to diffs being less usable, as Bertrand mentioned. On one hand, whitespace-only changes can be 'absorbed' by git using git diff --ignore-all-space and by GitHub. https://github.blog/2018-05-01-ignore-white-space-in-code-review/ On the other hand, if we decide to make changes with more impact, like moving things on different lines, then we'll lose some of the ability to check history. I think there are some open questions at this point: 1. What kind of formatter do we want to apply? We can either go with something minimalistic like spaces vs tabs, indent size, max line length or we can go with a comprehensive formatter. 2. How to we enforce this? Ideally this would be IDE, Maven build, and nicely surfaced in GitHub PRs. 3. What is the impact if applied globally? To put it otherwise, what percentage of lines would be change if we just applied to the whole Sling codebase? At some point I developed [1] to help with configuring preferences in the IDE, would be happy to enhance it if needed. Thanks, Robert [1]: https://github.com/mojohaus/reusable-ide-preferences
