The Key Concept of Observation Scores and Ratings

This page applies to the CodeImprover Metrics app

Observation Score – the absolute value

The CodeImprover Analytical Engine calculates values referred to as a metric in absolute terms. This calculated (or measured) metric value is a signed integer, negative, 0 (zero), or positive. This metric value is henceforth referred to as the Observation Score. 

By definition, a snapshot of a complete and ideal maximum quality codebase has the Observation Score value of zero.

Every occurrence of “not quality” source code statement lowers the quality and subtracts from the Observation Score sum. Severe quality incidents subtract more than less severe incidents. This means that the Observation Score sum expresses an absolute amount of quality – where 0 is best and -∞ ( minus infinite) is worst.

Observation Scores in details

Almost every codebase has a negative Observation Score value and a large piece of code is more likely to score a numerically larger negative number than a small piece of code.

Observation Scores are calculated within a set of metric categories. Each category has its algorithm. The Technical Reference overview page contains a list of all the metric categories used by CodeImprover. 

Observation Scores’ are directly comparable across metric categories. This means that -10 points for “cyclomatic complexity” corresponds (in severity) to -10 points for “number of parameters”.
These comparisons, calibration, or weighting of Observation Scores between categories are a topic of controversy and CodeImprover plans to offer each customer to define its custom weighting. For now, CodeImprover provides a qualified set of defaults that are suitable for most organizations.

Rating – the relative value

The CodeImprover Rating expresses Observation Score relative to the amount of code, measured in lines containing program statements. The rating is a decimal number larger than 0 and no bigger than 5. 

The metrics and rating system is calibrated so that Ratings below 3, in general, equals bad quality code and Ratings above 4 indicate good quality code. 

This relative Rating makes it possible to compare code quality across commits of various sizes, across developers with different levels of productivity, and across code bases of different sizes. 

Ratings in details

Neither empty source code lines nor lines containing only comments are included in the Significant Line Count number used for rating calculation. 

In math, a numerical large negative number is considered of smaller value than a numerical small negative number. This means that -22 has a smaller value than -12, although (or rather because) the number 22 is bigger than the number 12. Since CodeImprover uses Observation Score 0 (zero) as the ideal code quality and that there is virtually no bottom limit of how small the code quality can become (how low you can go) – this makes sense. 

The transformation of the Observation Score and Significant line count to a Rating follows a logarithmic scale.