oct
Loading...
Searching...
No Matches
oct.complexity.metrics Namespace Reference

Functions

float calculate_crap (int complexity, float coverage)

Detailed Description

Purpose
-------
Calculate CRAP scores from cyclomatic complexity and statement coverage.

Responsibilities
----------------
- Apply the pinned CRAP formula without rounding measurements.
- Reject invalid complexity and coverage inputs.

Diagnostics
-----------
Domain: OCT-COMPLEXITY
Levels:
    L2 - lifecycle
    L3 - calculation details
    L4 - deep tracing

Contracts
---------
- The formula is ``CC^2 * (1 - coverage)^3 + CC``.
- Complexity is a positive integer and coverage is in the inclusive range zero to one.

Dependencies
------------

Function Documentation

◆ calculate_crap()

float oct.complexity.metrics.calculate_crap ( int complexity,
float coverage )
Return ``CC^2 * (1 - coverage)^3 + CC``.

Complexity is a positive integer and coverage is a fraction in the
inclusive range zero through one. Failing fast on invalid measurements
prevents the reporting layer from presenting approximate scores.

Definition at line 38 of file metrics.py.