The unclean code sonar plugin aims to capture complex code, metrics of design and architectural level. Provides a guided way for the developers to improve code quality. Inspired by the book clean code by Robert Martin (Uncle Bob).
It aims to cover the last two axes.
Potential bugsCoding rulesTestsDuplicationsComments- Architecture and design
- Complexity
Download the jar here and copy into the SONAR_INSTALLED_PATH\extensions\plugins
and restart the sonar server.
If you dont have local setup of sonar, follow the instruction and setup local sonar.
Login to your sonar server: http://localhost:9000.
Search for rule repository with the uncleancode
, it will list down all the rules bundled in this plugin.
Then, you can add rules under the appropriate quality profile.
AvoidPublicBooleanParameterRule - It enforces SRP. If a public method has a boolean parameter, which means the method is performing more than one responsibility.
AvoidMultipleParameterRule - To keep the API definition simple and concise, avoid using more than two parameters.
AvoidNullCheckInPrivateMethodRule - It enforces SRP by identifying the null checking inside the private method. This leads to more than one responsibility, similar to boolean input parameter, if-else branch with null and non-null value. It avoids defensive way of programming with lot of null-checks inside any private methods. The validity of the input parameters should have been done in the public methods.
PrivateMethodPositionRule - It improves readability of a class, push all the private methods to the bottom of the class and keep the public methods at the top. Anyone who reads the class would be interested in public methods initially, also the tiny private methods can be mostly understandable by its name.
there are more to add..,