code-quality

Code quality inspection and linting commands for web audio apps. Includes detection of dead code, magic numbers, type safety issues, and naming inconsistencies.

SKILL.md

GitHub

πŸ” Code Quality Skill

μ½”λ“œ ν’ˆμ§ˆ 검사λ₯Ό μœ„ν•œ λͺ…λ Ήμ–΄ 및 체크리슀트.

🎯 μš©λ„

  • μ‚¬μš©λ˜μ§€ μ•ŠλŠ” μ½”λ“œ 탐지
  • νƒ€μž… μ•ˆμ „μ„± 확인
  • μ½”λ”© μ»¨λ²€μ…˜ 검증
  • λ¦¬νŒ©ν† λ§ μš°μ„ μˆœμœ„ κ²°μ •

πŸ“‹ λΉ λ₯Έ 검사 λͺ…λ Ήμ–΄

1. νƒ€μž… μ•ˆμ „μ„±

# any νƒ€μž… μ‚¬μš© 확인
grep -rn ": any" --include="*.ts" --include="*.tsx" src/

# νƒ€μž… μ—λŸ¬ 체크 (TypeScript)
npx tsc --noEmit

2. μ‚¬μš©λ˜μ§€ μ•ŠλŠ” μ½”λ“œ

# TODO/FIXME 주석 μ°ΎκΈ°
grep -rn "TODO\|FIXME\|XXX" --include="*.ts" --include="*.tsx" src/

# μ‚¬μš©λ˜μ§€ μ•ŠλŠ” exports (μ„€μΉ˜ ν•„μš”)
npx ts-unused-exports tsconfig.json --silent

3. μ½”λ”© μ»¨λ²€μ…˜

# ν•˜λ“œμ½”λ”©λœ 색상 (Tailwind ν”„λ‘œμ νŠΈ)
grep -rn "bg-\[#" --include="*.tsx" src/
grep -rn "text-\[#" --include="*.tsx" src/
grep -rn "border-\[#" --include="*.tsx" src/

# 맀직 λ„˜λ²„ (2자리 이상)
grep -rn "[^0-9a-zA-Z][0-9]\{2,\}[^0-9]" --include="*.ts" --include="*.tsx" src/ | grep -v "//"

# 짧은 λ³€μˆ˜λͺ… (1-2κΈ€μž)
grep -rn "\b[a-z]\{1,2\}\b\s*=" --include="*.ts" --include="*.tsx" src/

4. 쀑볡 μ½”λ“œ

# Copy-Paste Detector (μ„€μΉ˜ ν•„μš”)
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. μ½”λ“œ μŠ€νƒ€μΌλ§Œ 영ν–₯
  2. νŠΉμ • 파일만 영ν–₯
  3. λͺ¨λ“ˆ 전체 영ν–₯
  4. μ—¬λŸ¬ λͺ¨λ“ˆ 영ν–₯
  5. μ‹œμŠ€ν…œ 전체 영ν–₯

λΉˆλ„ (1-5)

  1. 1번만 λ°œμƒ
  2. 2-3κ³³
  3. 4-10κ³³
  4. 10-50κ³³
  5. 50κ³³ 이상

λ‚œμ΄λ„ (1-5)

  1. 5λΆ„ 이내
  2. 30λΆ„ 이내
  3. 2μ‹œκ°„ 이내
  4. 1일 이내
  5. 1일 이상

πŸ”— κ΄€λ ¨ 도ꡬ

ꢌμž₯ μ„€μΉ˜

# ESLint + TypeScript
npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

# 쀑볡 μ½”λ“œ 탐지
npm install -g jscpd

# μ‚¬μš©λ˜μ§€ μ•ŠλŠ” exports
npm install -g ts-unused-exports

# λ³΅μž‘λ„ 뢄석
npm install -g es6-plato

VS Code ν™•μž₯

  • SonarLint: μ‹€μ‹œκ°„ μ½”λ“œ ν’ˆμ§ˆ 체크
  • Code Metrics: λ³΅μž‘λ„ ν‘œμ‹œ
  • TODO Highlight: TODO/FIXME κ°•μ‘°
  • Better Comments: 주석 λΆ„λ₯˜