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
HighCyclomatic: Cyclomatic complexity exceeds thresholdHighCognitive: Cognitive complexity exceeds thresholdCriticalComplexity: Both cyclomatic AND cognitive exceed thresholds
§Structure Predicates
DeepNesting: Nesting depth exceeds thresholdLongMethod: Line count exceeds thresholdTooManyParameters: Parameter count exceeds threshold (placeholder)
§Risk Predicates (Composed)
HighRisk: High complexity AND low coverageCriticalRisk: Critical complexity AND no coverageModerateRisk: High complexity OR low coverage
§Coverage Predicates
LowCoverage: Coverage below thresholdNoCoverage: Coverage is zero or absentPartialCoverage: Coverage between 0% and threshold
Structs§
- Critical
Complexity - Predicate for critical complexity (both cyclomatic AND cognitive exceed thresholds).
- Critical
Risk - Critical-risk predicate: Critical complexity AND no coverage.
- Debt
Findings - Collection of predicate evaluation results for a function.
- Debt
Predicates - Factory for creating configured debt detection predicates.
- Deep
Nesting - Predicate for deep nesting depth.
- Function
With Coverage - Metrics with coverage for risk evaluation.
- High
Cognitive - Predicate for high cognitive complexity.
- High
Cyclomatic - Predicate for high cyclomatic complexity.
- High
Risk - High-risk predicate: High complexity AND low coverage.
- Long
Method - Predicate for long methods.
- LowCoverage
- Predicate for low test coverage.
- Moderate
Risk - Moderate-risk predicate: High complexity OR low coverage.
- NoCoverage
- Predicate for zero (or absent) test coverage.
- Partial
Coverage - Predicate for partial coverage (between 0% and threshold).
- Predicate
Result - Result of predicate evaluation with context.
- TooMany
Parameters - Predicate for too many parameters.