Code Rating/Code Smells¶
Introduction¶
Scrutinizer uses a rating algorithm for the different elements of your code such as classes, methods or functions which combines their different metrics (such as complexity, coupling, cohesion, etc.) in a single rating score.
The rating is done with the grades A-F; A being the best rating and F the worst. From the individual rating, we compute a weighted average for your project which is based on a scale from 0 (worst) to 10 (best).
Why code rating is better than hard issues¶
In particular for such architectural issues like complexity, we believe that a rating is much better reflecting the state of your project than a hard issue being raised at a certain threshold.
For example, if you have two methods one with complexity of 100 and another one with complexity of 10. For both methods, a tool can raise an issue that they are too complex. However, the method with 100 complexity much more likely needs your attention than the method that just has a complexity of 10.
Besides, once an issue is raised, no new issue will be raised even if the complexity of a method keeps increasing. With code rating however, as complexity increases further the rating will go down further.
Configuration¶
Enabling code rating in your project is very easy:
build:
nodes:
analysis:
tests:
override:
# Add the respective Scrutinizer analysis for your language like
- go-scrutinizer-run
- js-scrutinizer-run
- java-scrutinizer-run
- php-scrutinizer-run
- py-scrutinizer-run
- ruby-scrutinizer-run
# ....