c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4.9 KiB
4.9 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-cyclomatic-complexity | Cyclomatic Complexity | 10_Wiki/Topics | verified | self |
|
none | A | 0.92 | applied |
|
2026-05-10 | pending |
|
Cyclomatic Complexity
매 한 줄
"매 function 의 linearly independent path 수". Thomas McCabe (1976) 가 정의. 매 control-flow graph 매
M = E − N + 2P(edges − nodes + 2×components). 2026 현재 ruff, eslint, SonarQube 매 default 로 측정; high CC ↔ test difficulty + bug rate correlation 매 empirical.
매 핵심
매 계산
- 각 decision point (if, for, while, case, &&, ||, ternary, catch) 마다 +1.
- Base 1 (single path) + decisions.
- Function 1 → straight-line.
- Function 10+ → moderate.
- Function 20+ → complex, refactor 권장.
- Function 50+ → 매 unmaintainable.
매 의미
- Test path 수 lower bound.
- Reading difficulty proxy.
- Bug density correlation — 매 empirical study.
- NOT measure of correctness, performance, design quality.
매 응용
- CI gate —
max-complexity: 10lint rule. - Code review — high-CC function 매 split 요청.
- Refactoring target prioritization.
- Legacy modernization metric.
💻 패턴
CC 계산 example (Python)
def classify(score): # base 1
if score >= 90: # +1
return 'A'
elif score >= 80: # +1
return 'B'
elif score >= 70: # +1
return 'C'
else:
return 'F'
# CC = 4
Lint config (ruff, 2026)
# pyproject.toml
[tool.ruff.lint]
select = ["C90"] # mccabe
[tool.ruff.lint.mccabe]
max-complexity = 10
ESLint
{
"rules": {
"complexity": ["error", { "max": 10 }]
}
}
Refactor: replace conditional with polymorphism
// before — CC 5
function area(shape: Shape): number {
if (shape.kind === 'circle') return Math.PI * shape.r ** 2;
if (shape.kind === 'square') return shape.s ** 2;
if (shape.kind === 'rect') return shape.w * shape.h;
if (shape.kind === 'triangle') return 0.5 * shape.b * shape.h;
throw new Error('unknown');
}
// after — CC 1 per class
abstract class Shape { abstract area(): number; }
class Circle extends Shape { area() { return Math.PI * this.r ** 2; } }
class Square extends Shape { area() { return this.s ** 2; } }
Refactor: guard clauses (early return)
# before — CC 4
def process(user):
if user is not None:
if user.active:
if user.has_permission:
do_work(user)
# after — CC 4 still, but readability ↑
def process(user):
if user is None: return
if not user.active: return
if not user.has_permission: return
do_work(user)
Refactor: table dispatch
# before — CC 6
def handle(event_type, payload):
if event_type == 'created': return on_created(payload)
elif event_type == 'updated': return on_updated(payload)
elif event_type == 'deleted': return on_deleted(payload)
# ...
# after — CC 2
HANDLERS = {'created': on_created, 'updated': on_updated, 'deleted': on_deleted}
def handle(event_type, payload):
handler = HANDLERS.get(event_type)
if not handler: raise ValueError(event_type)
return handler(payload)
radon (Python CLI)
$ radon cc -s -a app/
app/service.py
F 42:0 process_order - C (12)
F 88:0 validate - A (3)
Average complexity: B (6.2)
매 결정 기준
| 상황 | Approach |
|---|---|
| New code | CC ≤ 10 hard limit |
| Legacy refactor | CC > 15 → split 우선 |
| Pure data transform | higher CC OK if linear (case/match) |
| State machine | use explicit FSM library |
기본값: max-complexity 10 in lint config; warn at 8.
🔗 Graph
- 부모: Static Analysis
- 응용: Refactoring_Best_Practices · Code Review · CI Gates
- Adjacent: Test Coverage · SOLID (Single Responsibility)
🤖 LLM 활용
언제: high-CC function 매 refactor 제안 (split, polymorphism, table dispatch). 언제 X: pure metric calculation (deterministic tool 가 더 빠름).
❌ 안티패턴
- CC 만 보고 quality 판단: linear case dispatch 매 high CC 지만 매 simple.
- Hard limit 무조건 enforcement: 매 split 의 split 매 fragmentation.
- CC ↓ 위해 boolean parameter 추가: flag argument anti-pattern.
- Cognitive complexity 무시: 매 nesting depth, recursion 매 더 중요할 수도.
🧪 검증 / 중복
- Verified (McCabe 1976 A Complexity Measure, ruff/SonarQube docs 2026).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full content with refactoring patterns |