| name | code-quality |
| description | Code quality inspection and linting commands for web audio apps. Includes detection of dead code, magic numbers, type safety issues, and naming inconsistencies. |
🔍 Code Quality Skill
코드 품질 검사를 위한 명령어 및 체크리스트.
🎯 용도
- 사용되지 않는 코드 탐지
- 타입 안전성 확인
- 코딩 컨벤션 검증
- 리팩토링 우선순위 결정
📋 빠른 검사 명령어
1. 타입 안전성
grep -rn ": any" --include="*.ts" --include="*.tsx" src/
npx tsc --noEmit
2. 사용되지 않는 코드
grep -rn "TODO\|FIXME\|XXX" --include="*.ts" --include="*.tsx" src/
npx ts-unused-exports tsconfig.json --silent
3. 코딩 컨벤션
grep -rn "bg-\[#" --include="*.tsx" src/
grep -rn "text-\[#" --include="*.tsx" src/
grep -rn "border-\[#" --include="*.tsx" src/
grep -rn "[^0-9a-zA-Z][0-9]\{2,\}[^0-9]" --include="*.ts" --include="*.tsx" src/ | grep -v "//"
grep -rn "\b[a-z]\{1,2\}\b\s*=" --include="*.ts" --include="*.tsx" src/
4. 중복 코드
npx jscpd --min-lines 5 --min-tokens 50 src/
📊 품질 지표
파일 크기 분석
find src -name "*.tsx" -o -name "*.ts" | xargs wc -l | sort -rn | head -20
권장 기준
| 지표 | 양호 | 주의 | 위험 |
|---|
| 파일 라인 수 | < 200 | 200-500 | > 500 |
| 함수 파라미터 | < 3 | 3-5 | > 5 |
| useEffect 개수 | < 3 | 3-5 | > 5 |
| 중첩 깊이 | < 3 | 3-4 | > 4 |
🛠️ 자동화 스크립트
quick-check.sh
#!/bin/bash
echo "=== Code Quality Check ==="
echo -e "\n📌 TODO/FIXME count:"
grep -rn "TODO\|FIXME" --include="*.ts" --include="*.tsx" src/ | wc -l
echo -e "\n📌 any type usage:"
grep -rn ": any" --include="*.ts" --include="*.tsx" src/ | wc -l
echo -e "\n📌 Hardcoded colors:"
grep -rn "bg-\[#\|text-\[#" --include="*.tsx" src/ | wc -l
echo -e "\n📌 Large files (>300 lines):"
find src -name "*.tsx" -o -name "*.ts" | xargs wc -l | sort -rn | awk '$1 > 300 {print}'
echo -e "\n📌 Type check:"
npx tsc --noEmit 2>&1 | tail -5
echo -e "\n=== Done ==="
📝 리팩토링 우선순위 계산
점수 공식
우선순위 = (영향도 × 5) + (빈도 × 3) + (난이도 × -2)
영향도 (1-5)
- 코드 스타일만 영향
- 특정 파일만 영향
- 모듈 전체 영향
- 여러 모듈 영향
- 시스템 전체 영향
빈도 (1-5)
- 1번만 발생
- 2-3곳
- 4-10곳
- 10-50곳
- 50곳 이상
난이도 (1-5)
- 5분 이내
- 30분 이내
- 2시간 이내
- 1일 이내
- 1일 이상
🔗 관련 도구
권장 설치
npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm install -g jscpd
npm install -g ts-unused-exports
npm install -g es6-plato
VS Code 확장
- SonarLint: 실시간 코드 품질 체크
- Code Metrics: 복잡도 표시
- TODO Highlight: TODO/FIXME 강조
- Better Comments: 주석 분류