Skip to main content

Module predicates

Module predicates 

Source
Expand description

Composable predicate system for debt detection rules.

This module provides declarative predicates for detecting technical debt patterns. Predicates are built using stillwater’s predicate combinators, enabling:

  • Composition: Combine predicates with and(), or(), not()
  • Testability: Each predicate is independently testable
  • Configurability: Thresholds are parameterized via config
  • Self-documentation: Each predicate describes what it detects

§Example

use debtmap::debt::predicates::*;

// Create predicates with thresholds
let high_complexity = HighCyclomatic::new(21);
let low_coverage = LowCoverage::new(0.5);

// Compose for high-risk detection
let high_risk = high_complexity.and(low_coverage);

// Check against function metrics
if high_risk.check(&metrics) {
    println!("High risk function detected!");
}

§Available Predicates

§Complexity Predicates

§Structure Predicates

§Risk Predicates (Composed)

§Coverage Predicates

Structs§

CriticalComplexity
Predicate for critical complexity (both cyclomatic AND cognitive exceed thresholds).
CriticalRisk
Critical-risk predicate: Critical complexity AND no coverage.
DebtFindings
Collection of predicate evaluation results for a function.
DebtPredicates
Factory for creating configured debt detection predicates.
DeepNesting
Predicate for deep nesting depth.
FunctionWithCoverage
Metrics with coverage for risk evaluation.
HighCognitive
Predicate for high cognitive complexity.
HighCyclomatic
Predicate for high cyclomatic complexity.
HighRisk
High-risk predicate: High complexity AND low coverage.
LongMethod
Predicate for long methods.
LowCoverage
Predicate for low test coverage.
ModerateRisk
Moderate-risk predicate: High complexity OR low coverage.
NoCoverage
Predicate for zero (or absent) test coverage.
PartialCoverage
Predicate for partial coverage (between 0% and threshold).
PredicateResult
Result of predicate evaluation with context.
TooManyParameters
Predicate for too many parameters.