f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
208 lines
6.8 KiB
Markdown
208 lines
6.8 KiB
Markdown
---
|
|
id: wiki-2026-0508-코드-품질-관리-및-자동화-code-quality-mana
|
|
title: 코드 품질 관리 및 자동화 (Code Quality Management and Automation)
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Code Quality Management, Code Quality Automation, CI Quality Gates]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [code-quality, automation, ci-cd, devops, sast]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: typescript
|
|
framework: github-actions
|
|
---
|
|
|
|
# 코드 품질 관리 및 자동화 (Code Quality Management and Automation)
|
|
|
|
## 매 한 줄
|
|
> **"매 quality 의 의 의 의 manual review 의 의 의 X, 매 pipeline 의 의 의 의 의 enforce"**. 매 lint / format / type / test / coverage / security / performance 의 의 의 의 한 의 의 의 PR pipeline 의 의 의 의 의 의 quality gate. 매 2026 — 매 SonarQube + Semgrep + Claude review 의 의 의 의 standard.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 Quality dimensions (ISO 25010)
|
|
1. **Functional suitability** — 매 correctness, 매 completeness.
|
|
2. **Reliability** — 매 fault tolerance, 매 availability.
|
|
3. **Performance** — 매 response time, 매 throughput.
|
|
4. **Usability** — 매 UX, 매 accessibility.
|
|
5. **Security** — 매 confidentiality, 매 integrity.
|
|
6. **Maintainability** — 매 modularity, 매 testability.
|
|
7. **Portability** — 매 adaptability, 매 installability.
|
|
|
|
### 매 Automation pyramid
|
|
- **Pre-commit** — 매 fast (sec) — format, lint, secret scan.
|
|
- **PR** — 매 medium (min) — type, unit test, SAST, LLM review.
|
|
- **Main / nightly** — 매 slow (hour) — integration, E2E, perf, DAST.
|
|
- **Production** — 매 continuous — RUM, error tracking, drift.
|
|
|
|
### 매 Key metrics
|
|
- **Cyclomatic complexity** — 매 path count.
|
|
- **Cognitive complexity** (SonarSource) — 매 readability.
|
|
- **Test coverage** — 매 line / branch / mutation.
|
|
- **Tech debt ratio** — 매 SQALE method.
|
|
- **Code smells** — 매 ESLint, SonarQube rule.
|
|
- **Duplicated lines** — 매 PMD CPD.
|
|
|
|
### 매 2026 standard stack
|
|
- **Format**: Prettier, Biome, Black, Ruff format, gofmt.
|
|
- **Lint**: ESLint, Biome, Ruff, golangci-lint, Clippy.
|
|
- **Type**: TypeScript, Pyright, mypy.
|
|
- **Test**: Vitest, Jest, pytest, go test.
|
|
- **Coverage**: c8, Istanbul, coverage.py.
|
|
- **SAST**: Semgrep, CodeQL, Snyk.
|
|
- **Quality**: SonarQube / SonarCloud.
|
|
- **AI**: Claude Code Action, CodeRabbit, Greptile.
|
|
|
|
## 💻 패턴
|
|
|
|
### 매 Pre-commit (full)
|
|
```yaml
|
|
# .pre-commit-config.yaml
|
|
default_install_hook_types: [pre-commit, commit-msg]
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v5.0.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
- id: end-of-file-fixer
|
|
- id: check-yaml
|
|
- id: check-merge-conflict
|
|
- repo: https://github.com/biomejs/pre-commit
|
|
rev: v0.6.0
|
|
hooks: [{id: biome-check}]
|
|
- repo: https://github.com/gitleaks/gitleaks
|
|
rev: v8.20.0
|
|
hooks: [{id: gitleaks}]
|
|
- repo: https://github.com/commitizen-tools/commitizen
|
|
rev: v4.0.0
|
|
hooks: [{id: commitizen, stages: [commit-msg]}]
|
|
```
|
|
|
|
### 매 GitHub Actions — quality gate
|
|
```yaml
|
|
name: Quality
|
|
on: [pull_request]
|
|
jobs:
|
|
quality:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with: { fetch-depth: 0 }
|
|
- uses: actions/setup-node@v4
|
|
with: { node-version: 22, cache: pnpm }
|
|
- run: pnpm install --frozen-lockfile
|
|
- run: pnpm exec biome ci .
|
|
- run: pnpm exec tsc --noEmit
|
|
- run: pnpm test --coverage
|
|
- uses: codecov/codecov-action@v5
|
|
- uses: returntocorp/semgrep-action@v1
|
|
- uses: SonarSource/sonarcloud-github-action@v3
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
- uses: anthropics/claude-code-action@v1
|
|
with:
|
|
model: claude-opus-4-7
|
|
```
|
|
|
|
### 매 SonarQube quality gate
|
|
```yaml
|
|
# sonar-project.properties
|
|
sonar.projectKey=myorg_myrepo
|
|
sonar.organization=myorg
|
|
sonar.sources=src
|
|
sonar.tests=tests
|
|
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
sonar.qualitygate.wait=true
|
|
|
|
# 매 PR 의 의 의 의 의 fail 의 의 의 의:
|
|
# - new code coverage < 80%
|
|
# - new bugs > 0
|
|
# - new vulnerabilities > 0
|
|
# - new code smells > 5
|
|
```
|
|
|
|
### 매 Mutation testing (StrykerJS)
|
|
```json
|
|
{
|
|
"packageManager": "pnpm",
|
|
"testRunner": "vitest",
|
|
"coverageAnalysis": "perTest",
|
|
"thresholds": { "high": 80, "low": 60, "break": 50 }
|
|
}
|
|
```
|
|
|
|
### 매 Performance budget (Lighthouse CI)
|
|
```json
|
|
{
|
|
"ci": {
|
|
"collect": { "url": ["https://staging.example.com"] },
|
|
"assert": {
|
|
"assertions": {
|
|
"categories:performance": ["error", { "minScore": 0.9 }],
|
|
"interactive": ["error", { "maxNumericValue": 3000 }]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### 매 Dependency audit
|
|
```bash
|
|
pnpm audit --prod --audit-level=high
|
|
trivy fs --severity HIGH,CRITICAL .
|
|
osv-scanner -r .
|
|
```
|
|
|
|
### 매 Visual regression (Playwright)
|
|
```typescript
|
|
test("homepage matches snapshot", async ({ page }) => {
|
|
await page.goto("/");
|
|
await expect(page).toHaveScreenshot("homepage.png", {
|
|
maxDiffPixelRatio: 0.01,
|
|
});
|
|
});
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| 매 small team / OSS | 매 Biome + Vitest + Codecov + CodeRabbit |
|
|
| 매 enterprise | 매 SonarQube + Semgrep + Snyk + Claude |
|
|
| 매 perf-critical | 매 + Lighthouse CI + k6 |
|
|
| 매 UI-heavy | 매 + Playwright visual + Chromatic |
|
|
| 매 supply chain risk | 매 + SLSA + Sigstore + SBOM |
|
|
|
|
**기본값**: 매 pre-commit (Biome + gitleaks) + PR (test + coverage + SAST + Claude) + main (E2E + perf).
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[DevOps]]
|
|
- 변형: [[자동화된 코드 리뷰]] · [[Test Automation]]
|
|
- 응용: [[SonarQube]] · [[Semgrep]] · [[GitHub Actions]]
|
|
- Adjacent: [[Mutation Testing]] · [[Supply Chain Security]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: 매 quality gate 의 의 의 의 design, 매 metric threshold 의 의 의 의 의 calibrate, 매 flaky test 의 의 의 의 의 root-cause.
|
|
**언제 X**: 매 fundamental architectural quality — 매 structural review 의 의 의 의 human + design doc 의 의 필요.
|
|
|
|
## ❌ 안티패턴
|
|
- **Coverage worship**: 매 100% coverage 의 의 의 의 의 의 quality 의 의 의 의 X.
|
|
- **Quality theater**: 매 lint 의 의 의 의 의 통과 의 의 의 의, 매 hidden disable 의 의 의 의 thousands.
|
|
- **Bypass habitually**: 매 `--no-verify` 의 의 의 의 의 routine.
|
|
- **Metric manipulation**: 매 cyclomatic 의 의 의 의 의 의 의 의 game (extract method 의 의 의 의 thoughtless).
|
|
- **Slow gate**: 매 PR pipeline 의 의 의 의 30min — 매 dev 의 의 의 의 disengage.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified — SonarQube docs (2026); ISO/IEC 25010:2023; *Continuous Delivery* (Humble & Farley); GitHub Actions docs.
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — automation pyramid + ISO 25010 + 2026 stack |
|