From qa-code-quality
Run Lizard against production source to enforce per-function cyclomatic complexity (CCN), NLOC, and parameter-count thresholds - language-agnostic (30+ languages). Scoped to production code via `-x"./tests/*"`; test complexity is owned by qa-test-review.
How this skill is triggered — by the user, by Claude, or both
Slash command
/qa-code-quality:lizard-complexityThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Lizard analyzes source code per function for **NLOC** (non-comment LoC),
Lizard analyzes source code per function for NLOC (non-comment LoC), CCN (cyclomatic complexity), token count, and parameter count across 30+ languages including C/C++, Java, Python, JavaScript, Go, Rust, TypeScript, Swift, Kotlin (per the Lizard README). Default CCN warning threshold is 15.
pip install lizard
Or run the standalone script:
python lizard.py path/to/code
Per the Lizard README, no external deps required.
lizard src/
Default output groups by file with per-function NLOC/CCN/token/param counts. Default warning threshold: CCN ≥ 15.
lizard src/ \
-x"./tests/*" \
-x"./vendor/*" \
-C 10 \
-L 100 \
-a 5
| Flag | Meaning |
|---|---|
-x PATTERN | Exclude (must include tests/** for production-only scope) |
-C N | CCN warning threshold (default 15; tighten to 10 for new codebases) |
-L N | Max function NLOC (default 1000; tighten to 80 - 100) |
-a N | Max parameter count (5 = "if you need more, pass an object") |
# CSV for grep / jq pipelines
lizard src/ -x"./tests/*" -C 10 --csv > lizard.csv
# XML for CI parsers (cppncss-style)
lizard src/ -x"./tests/*" -C 10 -X > lizard.xml
# HTML for human review
lizard src/ -x"./tests/*" -C 10 -H > lizard.html
lizard src/ -x"./tests/*" -C 10 -L 100 -a 5 -w
EXIT=$?
if [ "$EXIT" -ne 0 ]; then
echo "Complexity threshold breached. See report."
exit 1
fi
-w prints warnings only (clang/gcc style). Lizard exits non-zero
when any function exceeds the configured threshold.
# Only Python
lizard src/ -l python -C 10
# Only TypeScript + JS
lizard src/ -l typescript -l javascript -C 10
Useful when a polyglot repo has language-specific budgets (e.g., Python tolerates higher CCN than C).
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Run on whole repo including tests | Test setup helpers ("create user with 12 fields") look complex; tests get refactored away from clarity | Always exclude tests/, spec/ (Step 3) |
| Set CCN threshold to default (15) | Too lax for new code | Start at 10 for new code; track existing code as baseline |
| Block PRs on absolute count | Legacy code can't add a single line | Diff-only: scan PR-changed functions only with git diff --name-only filter |
| Refactor for CCN at expense of clarity | Splitting a clear linear function into 4 helpers raises overall complexity | Use CCN as a smell signal, not a hard rule |
| Skip parameter-count guard | "God functions" with 12 args slip through | -a 5 enforces object-arg style |
qa-code-quality/sonarqube-quality-perspective for cognitive
complexity if needed.npx claudepluginhub testland/qa --plugin qa-code-qualityProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.