RiskRanking-Coverage

Test coverage of a finding, taken from coverage reports

Required inputs: IR

Adding this rule to the list of active RiskRanking actions creates a rank factor column in the Dashboard. The name of the list entry is shown as the column name.

This rule fills its rank factor column for each finding from test coverage reports in the lcov tracefile or the Cobertura XML format. Both formats carry line and branch coverage. Function coverage is exact in lcov and derived from the first line of a method in Cobertura. MC/DC coverage is only available in lcov tracefiles written by lcov 2.2 or later. For the reports of Coco, use RiskRanking-CocoCoverage. By default, a finding scores high if the code at its location was not or only rarely executed by the tests, so findings in untested code rank above findings in tested code. A report is matched to the file of a finding by the longest common trailing part of their paths, so reports taken in another checkout apply as well.

Possible Messages

This rule has no predefined messages.

Options

The following places define options that affect this rule: Analysis-GlobalOptions

coverage_files

coverage_files : list[bauhaus.analysis.config.LayerRelativePath] = []

The coverage reports, each in the lcov tracefile or the Cobertura XML format.
 

metric

metric : CoverageMetric = 'line'

The kind of coverage a finding is scored by.
 

missing_value

missing_value : float | None = 0.5

The score for a finding whose place the reports do not cover, such as a line without code or a file that was not instrumented. If unset, such a finding gets no value from this rule.
 

saturation_hits

saturation_hits : int = 1

The execution or call count from which code counts as fully tested, on a logarithmic scale; the default of 1 only tells executed from not executed code.
 

scores_high

scores_high : CoverageRisk = 'untested'

Whether findings in rarely or in frequently executed code score high.
 

show_by_default

show_by_default : bool = False

Whether or not to show the column by default.
 

Option Types

These types are used by options listed above:

CoverageMetric

The kind of coverage a finding is scored by.
 

line

How often the line of a finding was executed.

branch

The share of the branches on the line of a finding that were taken.

function

How often the function around a finding was called.

mcdc

The share of the MC/DC condition outcomes on the line of a finding that were covered.

CoverageRisk

Which end of the coverage scale scores high.
 

untested

Findings in rarely executed code score high.

frequently_executed

Findings in frequently executed code score high.