Hello friends of clean code
I spent some time to understand where the rules from SonarQube came from and if there is any connection to the checkstyle.xml which is in the openmrs-core repository.
Here https://ci.openmrs.org/sonar/profiles to the right when you click on back up you can download an xml file with the rules. As you can see from the content of the file these are only FindBugs rules which are not in the github repository. Of 494 rules 165 are deprecated.
The checkstyle maven plugin was added back in 2010 (as you can find on github), the checkstyle.xml rules might be even older. The checkstyle.xml rules are not affecting SonarQube analysis as far I can see. They are not yet automatically synchronized with codacy (hope I’ll have that done soon).
I think we should formalize the code standard we want to adhere to. Lots of people are contributing and without automated checks in place the code looks like lots of different people wrote it. From my time as a newcomer I remember feeling confused by the inconsistencies in style (old, new unit test should styles; differences in indentations, …). At the moment checkstyle rules are not applied and FindBugs rules are applied but not on PRs and in a place where contributors sending PRs are probably not looking.
These rules (FindBugs, Checkstyle) should all be in the github repository for anyone to see and run locally and for automated tools (like codacy) to pick them up.
I suggest we base our checkstyle.xml rules on the one which is available from Google which also comes with detailed explanations http://checkstyle.sourceforge.net/google_style.html (I would make a few exceptions for ex. they use spaces, we currently use tabs).
Lets extract the FindBugs xml rule file from SonarQube profile OpenMRS, remove the deprecated rules and put the file into the github repository. (codacy supports FindBugs only for enterprise customers, but I asked their support if it would be possible for OpenMRS; maybe we are lucky)
Add this knowledge to https://wiki.openmrs.org/display/docs/Coding+Conventions