We have a new repo at https://github.com/openhab/static-code-analysis.
This contains tooling for static code analysis - it combines PMD with FindBugs and Checkstyle and is meant to help on code reviews of pull requests. My hope is that we can cover most “boring” parts of our coding guidelines, like the correct use of loggers, javadoc, license headers, manifest details, etc.
The tooling is not there yet, but you are all invited to help making it better (and closer to our coding guidelines).
For the start, I have released a version 0.0.1 and already integrated it into the openHAB2-addons build.
So what I would like to ask you is to locally run Maven with the “check” profile enabled, before creating a PR:
mvn clean install -P check
This will produce an HTML summary report in the
target folder (in the repo root), where you can click through the results.
A typical report of a single bundle e.g. looks like this. If you find false positives, please enter an issue for the tooling, so that it can be discussed and adapted.
Once we have good results from this tool, I would plan to activate it on PR builds, so that all PRs will have to pass this check as a very first gate. I think this will be helpful as it gives very quick early feedback to every contributor and it will reduce the manual work required for a code review afterwards - so please help making this tool as effective as possible!