-
Notifications
You must be signed in to change notification settings - Fork 0
Detector: Complexity
Jacob Centner edited this page Apr 10, 2026
·
1 revision
Flags Python functions that exceed cyclomatic complexity or line-count thresholds.
| Property | Value |
|---|---|
| Name | complexity |
| Tier | HEURISTIC |
| Languages | Python |
| External tool | None (uses Python ast) |
| LLM required | No |
| Confidence | 0.95 (source), 0.60 (test files) |
Python functions with:
- Cyclomatic complexity > 10 (decision points: if, elif, for, while, except, and, or, assert, ternary)
- Body longer than 50 lines
- Parses Python files with the
astmodule - Walks all
FunctionDefandAsyncFunctionDefnodes - Calculates McCabe cyclomatic complexity and body line count
- Flags functions exceeding either threshold
| Condition | Severity |
|---|---|
| CC > 20 or lines > 150 | HIGH |
| CC > 15 or lines > 100 | MEDIUM |
| Above threshold | LOW |
Test files (test_*.py, files under tests/) are always demoted to LOW severity with 0.60 confidence — complex tests are common and rarely worth refactoring.
[COMPLEXITY] src/httpx/_multipart.py:DataField.render_headers
Complex function: render_headers (cyclomatic complexity 14, 62 lines)
Severity: MEDIUM, Confidence: 0.95
| Repo | Findings | Notes |
|---|---|---|
| pip-tools | 20 | ~100% TP, some in tests |
| httpx | 31 | ~95% TP, ~15 in test files |
- Python-only (no JS/TS, Go, or Rust complexity analysis)
- Thresholds are not yet configurable via
sentinel.toml - Test files produce accurate but low-value findings (severity demoted to mitigate)
Local Repo Sentinel · MIT License
Getting Started
Reference
Detectors
- Detector: Todo Scanner
- Detector: Complexity
- Detector: Dead Code
- Detector: Dep Audit
- Detector: Docs Drift
- Detector: Unused Deps
- Detector: Lint Runner
- Detector: ESLint Runner
- Detector: Go Linter
- Detector: Rust Clippy
- Detector: Git Hotspots
- Detector: Stale Env
- Detector: Semantic Drift
- Detector: Test Coherence
- Detector: CI/CD Drift
- Detector: Architecture Drift
- Detector: Inline Comment Drift
- Detector: Intent Comparison
Advanced
Workflow