Hello Java devs,
We want to help you write clean test code!
However previously, Sonar was only using a limited set of rules on your test code, see the list here.
Sonar relies on your configuration to determine which files are the main code and which are tests. Our Maven and Gradle scanners handle this, but it can be configured, see the docs.
To improve, we’re reviewing our existing rules for main code to select those that make sense for test code as well.
As a first step, we’ve enabled two batches of 20 rules each. Thus, 40 additional rules are now enabled by default in test code!
Below is the complete list of rules. We are continuing this effort, so expect more rules in the future.
Enjoy the updates and don’t forget to let us know what you think.