← スキル一覧に戻る

quality-complexity-check
by mvillmow
Training framework written in Mojo
⭐ 11🍴 4📅 2026年1月24日
SKILL.md
name: quality-complexity-check description: Analyze code complexity metrics including cyclomatic complexity and nesting depth. Use to identify code that needs refactoring. mcp_fallback: none category: quality agent: test-engineer user-invocable: false
Complexity Check Skill
Analyze and report code complexity metrics.
When to Use
- Code review process
- Identifying refactoring candidates
- Maintaining code quality
- Before major releases
Quick Reference
# Analyze Python code
./scripts/check_complexity.py
# Generate full report
./scripts/complexity_report.sh > complexity.txt
# Check Mojo code
./scripts/check_mojo_complexity.sh
Complexity Metrics
Cyclomatic Complexity (CC)
Measures decision points (if, for, while):
| CC Range | Assessment | Action |
|---|---|---|
| 1-10 | Simple | Keep as is |
| 11-20 | Moderate | Consider refactoring |
| 21+ | Complex | Needs refactoring |
Nesting Depth
Maximum levels of nesting in function:
| Depth | Assessment | Action |
|---|---|---|
| 1-3 | Good | Keep as is |
| 4-5 | High | Consider flattening |
| 6+ | Very High | Refactor required |
Function Length
Lines of code in function:
| LOC | Assessment | Action |
|---|---|---|
| 1-20 | Good | Keep as is |
| 21-50 | Acceptable | Monitor |
| 51+ | Too long | Consider splitting |
Refactoring Patterns
Extract Function (High CC)
# Before (CC: 15)
def process(data):
if condition1:
if condition2:
if condition3:
for item in data:
if item.valid:
# process
# After (CC: 5)
def process(data):
if not is_valid(data):
return
filtered = filter_valid_items(data)
return process_items(filtered)
Flatten Nesting
Replace nested ifs with early returns:
# Before (depth: 5)
fn process(data):
if check1(data):
if check2(data):
if check3(data):
# complex logic
# After (depth: 2)
fn process(data):
if not check1(data): return
if not check2(data): return
if not check3(data): return
# complex logic
Workflow
# 1. Analyze code
./scripts/check_complexity.py
# 2. Review high-complexity functions
grep "CC:" complexity.txt | grep -E "CC: [2-9][0-9]|CC: [1-9][0-9]{2}"
# 3. Plan refactoring
# ... extract functions, flatten nesting ...
# 4. Re-analyze
./scripts/check_complexity.py
# 5. Verify improved
git diff complexity.txt
Error Handling
| Issue | Fix |
|---|---|
| Script not found | Check scripts/ directory |
| Syntax errors | Fix code syntax before analyzing |
| No output | Verify source files exist |
Thresholds
Project thresholds:
- Max CC per function: 15
- Max nesting depth: 4
- Max function length: 50 LOC
- Minimum test coverage: 80%
References
- Related skill:
phase-cleanupfor refactoring guidelines - Related skill:
quality-run-lintersfor complete quality check
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です