RiskRanking-CocoCoverage

Test coverage of a finding, taken from Coco 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 the test coverage that Coco measured, exported with cmreport --cobertura. Besides line and function coverage, a finding can be scored by statement block, decision, condition, MC/DC or multiple condition coverage, whichever coverage level cmreport wrote the report with. A report does not record its coverage level, so each level needs a report and an entry of its own. 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 Cobertura XML reports written by cmreport --cobertura.
 

metric

metric : CocoCoverageMetric = '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:

CocoCoverageMetric

The kind of Coco coverage a finding is scored by.
 

line

How often the line of a finding was executed.

function

How often the function around a finding was called.

coverage_level

The share of the outcomes on the line of a finding that were covered, at the coverage level the report was written with: --coverage-statement-block, --coverage-decision, --coverage-condition (the default), --coverage-mcdc or --coverage-mcc.

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.