Loading...
Loading...
Analyze code complexity and find refactor targets using radon/gocyclo. Triggers: "complexity", "analyze complexity", "find complex code", "refactor targets", "cyclomatic complexity", "code metrics".
npx skill4agent add boshu2/agentops complexity/complexity [path]git diff --name-only HEAD~5 2>/dev/null | grep -E '\.(py|go)$' | head -10# Check for Python files
ls *.py **/*.py 2>/dev/null | head -1 && echo "Python detected"
# Check for Go files
ls *.go **/*.go 2>/dev/null | head -1 && echo "Go detected"# Check if radon is installed
which radon || pip install radon
# Run cyclomatic complexity
radon cc <path> -a -s
# Run maintainability index
radon mi <path> -s# Check if gocyclo is installed
which gocyclo || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
# Run complexity analysis
gocyclo -over 10 <path>| Grade | CC Score | Meaning |
|---|---|---|
| A | 1-5 | Low risk, simple |
| B | 6-10 | Moderate, manageable |
| C | 11-20 | High risk, complex |
| D | 21-30 | Very high risk |
| F | 31+ | Untestable, refactor now |
.agents/complexity/YYYY-MM-DD-<target>.md# Complexity Report: <Target>
**Date:** YYYY-MM-DD
**Language:** <Python/Go>
**Files Analyzed:** <count>
## Summary
- Average CC: <score>
- Highest CC: <score> in <function>
- Functions over threshold: <count>
## Refactor Targets
### Critical (CC > 20)
| Function | File | CC | Recommendation |
|----------|------|-----|----------------|
| <name> | <file:line> | <score> | <how to simplify> |
### High (CC 11-20)
| Function | File | CC | Recommendation |
|----------|------|-----|----------------|
| <name> | <file:line> | <score> | <how to simplify> |
## Refactoring Recommendations
1. **<Function>**: <specific suggestion>
- Extract: <what to extract>
- Simplify: <how to simplify>
## Next Steps
- [ ] Address critical complexity first
- [ ] Create issues for high complexity
- [ ] Consider refactoring sprint