This is not an exhaustive list of metrics. For the full list, consult the api/metrics WebAPI on your SonarQube instance.

Complexity

Name

Key

Description

Complexity

complexity

It is the complexity calculated based on the number of paths through the code. Whenever the control flow of a function splits, the complexity counter gets incremented by one. Each function has a minimum complexity of 1. This calculation varies slightly by language because keywords and functionalities do.

Severity

Operational/security risk: This issue might lead to an unexpected behavior in production without impacting the integrity of the whole application. Ex: NullPointerException, badly caught exceptions, lack of unit tests, etc.

Tests

Metric

Key

Description

Condition coverage

branch_coverage

On each line of code containing some boolean expressions, the condition coverage simply answers the following question: 'Has each boolean expression been evaluated both to true and false?'. This is the density of possible conditions in flow control structures that have been followed during unit tests execution.

Condition coverage = (CT + CF) / (2*B)
where
CT = conditions that have been evaluated to 'true' at least once
CF = conditions that have been evaluated to 'false' at least once
B = total number of conditions

Condition coverage on new code

new_branch_coverage

Identical to Condition coverage but restricted to new / updated source code.

Condition coverage hits

branch_coverage_hits_data

List of covered conditions.

Conditions by line

conditions_by_line

Number of conditions by line.

Covered conditions by line

covered_conditions_by_line

Number of covered conditions by line.

Coverage

coverage

It is a mix of Line coverage and Condition coverage. Its goal is to provide an even more accurate answer to the following question: How much of the source code has been covered by the unit tests?

Coverage = (CT + CF + LC)/(2*B + EL)
where
CT = conditions that have been evaluated to 'true' at least once
CF = conditions that have been evaluated to 'false' at least once
LC = covered lines = lines_to_cover - uncovered_lines
B = total number of conditions
EL = total number of executable lines (lines_to_cover)

Coverage on new code

new_coverage

Identical to Coverage but restricted to new / updated source code.

Line coverage

line_coverage

On a given line of code, Line coverage simply answers the following question: Has this line of code been executed during the execution of the unit tests?. It is the density of covered lines by unit tests: