Improve code quality by using static analysis
We should work on improving code quality by using such metrics and techniques like:
- ABC Size metric
- Cyclomatic Complexity metric
- Perceived Complexity metric
- detecting duplication (maybe)
- detecting common code smells (maybe)
Currently we use Rubocop, flog and flay. Current cyclomatic complexity and perceived complexity threshold is 17, ABC Size threshold 60. Rubocop default for those metrics is accordingly: 6, 7 and 15, and similar values can be our goal.
We can also enable many different metrics, that will lead to better code, like ParameterLists, MethodLength. Tightening style checks maybe also a good thing to do.
Steps that we can take:
-
Remove flog in favor of Rubocop -
meta Decrease threshold ABC size step by step: https://gitlab.com/gitlab-org/gitlab-ce/issues/28202 -
Decrease CyclomaticComplexity to ... (add MR and threshold value) -
Decrease PerceivedComplexity to ... (add MR and threshold value)
Old title and description
Title: Improve code quality to pass flog and flay testing tools
-
make flog (code complexity) build in CI green for minimum score 50 -
make flay (code duplication) build in CI green for minimum mass 24