Reduce complexity.
Increase coverage.
That's the whole guardrail. Agents iterate by changing code and running tests, and the quality of that loop is decided by your codebase, not the model.
Coverage is the feedback loop
An agent editing untested code can't tell a fix from a regression. Where coverage is missing, agents guess.
Complexity is where agents fail
Deeply nested, many-branched methods blow past what any model reasons about reliably.
wCRAP gates both
One score per method. Gate it in CI, or hand the worst offenders to an agent as a work queue.
The math, without the math degree.
- cyc
- Cyclomatic complexity. Independent paths through the method. Each branch, loop, and conditional adds one.
- cog
- Cognitive complexity. How hard it is for a human to follow. Nested logic compounds the cost.
- cov
- Test coverage. The share of the method's lines exercised by tests, from 0 to 100%.
Pick a real method (from SlopGuard's own report)
Or build your own
A report agents and jq can eat.
Pretty text for humans, stable versioned JSON for everything else.
# Top of the leaderboard, straight from the dogfood run $ slopguard-swift analyze --path Sources --json | jq '.methods | sort_by(-.crap)[0]' { "qualifiedName" : "CrapAggregator.aggregate(fileReports:sourceRootURL:…)", "file" : "slopguard-core/Aggregation/CrapAggregator.swift", "complexity" : 17, "cognitiveComplexity" : 15, "coverage" : 0, "crap" : 270.97, "isCrappy" : true }
Use slopguard-swift to analyze this repo and find the method with the highest wCRAP score. Show me its file and line, then add tests or refactor until its score is under 30.
- name: Gate on wCRAP run: slopguard-swift analyze --path Sources --fail-over 50 # exits 2 if any method's wCRAP exceeds 50 → PR blocked
# Top of the leaderboard, straight from the dogfood run $ slopguard-ts analyze --path src --json | jq '.methods | sort_by(-.crap)[0]' { "qualifiedName": "CrapAggregator.aggregate", "file": "core/aggregation/crapAggregator.ts", "complexity": 20, "cognitiveComplexity": 16, "coverage": 0, "crap": 337.89, "isCrappy": true }
Use slopguard-ts to analyze this repo and find the method with the highest wCRAP score. Show me its file and line, then add tests or refactor until its score is under 30.
- name: Gate on wCRAP run: slopguard-ts analyze --path src --fail-over 50 # exits 2 if any method's wCRAP exceeds 50 → PR blocked
# Top of the leaderboard, straight from the dogfood run $ slopguard-go analyze --path . --json | jq '.methods | sort_by(-.crap)[0]' { "qualifiedName": "enumerate", "file": "core/diranalyzer.go", "complexity": 10, "cognitiveComplexity": 26, "coverage": 0, "crap": 276.12, "isCrappy": true }
Use slopguard-go to analyze this module and find the method with the highest wCRAP score. Show me its file and line, then add tests or refactor until its score is under 30.
- name: Gate on wCRAP run: slopguard-go analyze --path . --fail-over 50 # exits 2 if any method's wCRAP exceeds 50 → PR blocked
# Top of the leaderboard, straight from the dogfood run $ slopguard-kotlin analyze --path . --json | jq '.methods | sort_by(-.crap)[0]' { "qualifiedName": "ComplexityCalculator.walk", "file": "core/src/main/kotlin/.../ComplexityVisitor.kt", "complexity": 19, "cognitiveComplexity": 12, "coverage": 0, "crap": 243.10, "isCrappy": true }
Use slopguard-kotlin to analyze this module and find the method with the highest wCRAP score. Show me its file and line, then add tests or refactor until its score is under 30.
- name: Gate on wCRAP run: slopguard-kotlin analyze --path src/main/kotlin --fail-over 50 # exits 2 if any method's wCRAP exceeds 50 → PR blocked
# Top of the leaderboard, straight from the dogfood run $ slopguard-python analyze --path . --json | jq '.methods | sort_by(-.crap)[0]' { "qualifiedName": "_run_analyze", "file": "src/slopguard/cli.py", "complexity": 14, "cognitiveComplexity": 18, "coverage": 0, "crap": 267.87, "isCrappy": true }
Use slopguard-python to analyze this repo and find the method with the highest wCRAP score. Show me its file and line, then add tests or refactor until its score is under 30.
- name: Gate on wCRAP run: slopguard-python analyze --path . --fail-over 50 # exits 2 if any method's wCRAP exceeds 50 → PR blocked