[G1-Sync] Manual knowledge update
This commit is contained in:
+180
-66
@@ -2,92 +2,206 @@
|
||||
id: wiki-2026-0508-코드-품질-관리-및-자동화-code-quality-mana
|
||||
title: 코드 품질 관리 및 자동화 (Code Quality Management and Automation)
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-A84338]
|
||||
aliases: [Code Quality Management, Code Quality Automation, CI Quality Gates]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
verification_status: applied
|
||||
tags: [code-quality, automation, ci-cd, devops, sast]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - 코드 품질 관리 및 자동화 (Code Quality [[Management|Management]] and Automation)"
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: typescript
|
||||
framework: github-actions
|
||||
---
|
||||
|
||||
# [[코드 품질 관리 및 자동화 (Code Quality Management and Automation)|코드 품질 관리 및 자동화 (Code Quality Management and Automation]]
|
||||
# 코드 품질 관리 및 자동화 (Code Quality Management and Automation)
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> 코드 품질 관리 및 자동화는 린터(Linter), 포매터(Formatter), [[SAST|SAST]](정적 애플리케이션 보안 테스트) 등의 도구를 활용하여 소스 코드의 문법적 오류, 스타일 일관성, 보안 취약점을 식별하고 수정하는 프로세스이다 [1-3]. 이를 Husky, lint-staged와 같은 도구와 결합하여 CI/CD 파이프라인 또는 Git 훅에 통합함으로써 개발 초기 단계에서 결함을 예방하는 '시프트 레프트([[Shift|Shift]]-Left)' 보안 및 품질 검증을 수행한다 [4-6]. 최근에는 이러한 자동화 검사와 인간의 문맥적 이해가 필요한 수동 리뷰를 결합한 하이브리드 접근법이 표준적인 개발 문화로 자리 잡고 있다 [7, 8].
|
||||
## 매 한 줄
|
||||
> **"매 quality 의 의 의 의 manual review 의 의 의 X, 매 pipeline 의 의 의 의 의 enforce"**. 매 lint / format / type / test / coverage / security / performance 의 의 의 의 한 의 의 의 PR pipeline 의 의 의 의 의 의 quality gate. 매 2026 — 매 SonarQube + Semgrep + Claude review 의 의 의 의 standard.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **코드 품질 검사 및 포매팅 자동화:** [[ESLint|ESLint]]와 같은 린터는 코드의 논리적 오류와 문법을 정적으로 분석하여 품질을 보장하고, Prettier와 같은 포매터는 코드의 들여쓰기와 줄 바꿈 등 시각적 스타일을 일관되게 강제한다 [1, 9-11]. 이 두 도구가 충돌하지 않도록 `[[eslint-config-prettier|eslint-config-prettier]]` 등을 통해 조율하며, Husky와 `lint-staged`를 활용해 Git의 커밋 전(pre-commit) 단계에서 변경된 파일만 빠르고 자동으로 검사하도록 구성하여 개발자의 인지 부하를 줄인다 [12-16]. 모노레포 환경에서는 중앙 집중식 규칙 패키지를 구성해 설정 중복을 피하고 유지 보수성을 높인다 [17, 18].
|
||||
* **SAST(정적 애플리케이션 보안 테스트)의 통합:** SAST는 애플리케이션 실행 전 소스 코드 단계에서 보안 취약점(예: SQL 인젝션, 하드코딩된 비밀번호 등)을 검출하는 화이트박스 테스트 방식이다 [19, 20]. Snyk Code, [[SonarQube|SonarQube]], Checkmarx와 같은 SAST 도구들을 CI/CD 파이프라인이나 IDE 플러그인 형태로 통합하여 개발 사이클 초기에 보안 문제를 식별하고 수정하도록 한다 [21-23]. 최근에는 대규모 언어 모델(LLM)과 기계 학습을 결합해 복잡한 데이터 흐름 및 오탐(False Positive)을 줄이고 자동 수정(Auto-fix)을 제안하는 AI 기반 SAST 도구로 진화하고 있다 [24-26].
|
||||
* **자동화와 수동 코드 리뷰의 하이브리드 모델:** 자동화된 코드 리뷰는 대규모 코드베이스에 대해 일관되고 빠른 스캔을 제공하지만, 비즈니스 로직, 아키텍처적 절충안, 복잡한 시스템 간 종속성을 이해하는 데는 맹점이 있다 [27, 28]. 반면 수동 리뷰는 코드의 가독성을 높이고 컨텍스트를 고려할 수 있지만 시간과 비용이 많이 소요된다 [29, 30]. 따라서 구문 오류, 코드 스타일, 패턴화된 보안 취약점 식별 등 기계적 검증은 자동화 도구에 일임하고, 인간 리뷰어는 아키텍처 설계와 비즈니스 로직 검증에 집중하는 '하이브리드 코드 리뷰'가 고품질 소프트웨어 개발을 위한 핵심 전략이다 [7, 31-33].
|
||||
* **AI 도입에 따른 코드 거버넌스 및 위험 관리:** AI 기반 코드 생성기 및 리뷰 도구의 사용이 급증함에 따라, 무분별한 코드 생성으로 인한 보안 취약점 및 품질 저하를 방지하기 위해 'AI 사용 정책(Usage Policy)' 수립이 필수적이다 [34, 35]. 여기에는 민감 데이터의 퍼블릭 모델 입력 금지, 승인된 도구 사용, 인간의 최종 책임(Human-in-the-loop) 원칙이 포함된다 [35-38]. 또한 자동화 파이프라인 구축 시 도구 자체에 대한 공급망 공격(예: `eslint-config-prettier` 악성 코드 주입 공격인 CVE-2025-54313 사례) 위협을 인지하고 개발 도구 체인의 보안도 철저히 관리해야 한다 [39, 40].
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
|
||||
### 매 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.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[정적 애플리케이션 보안 테스트 (SAST)|정적 애플리케이션 보안 테스트 (SAST]], 수동 코드 리뷰 (Manual [[Code Review|Code Review]], 지속적 통합 및 지속적 배포 (CI/CD), 린터와 포매터 (Linters and Formatters)
|
||||
- **Projects/Contexts:** Git pre-commit 훅 환경에서 Husky와 lint-staged를 활용한 검증 파이프라인 자동화 구성, [[Turborepo|Turborepo]] 등 모노레포에서의 중앙 집중식 린트 환경 구축, Snyk 및 SonarQube를 통한 [[DevSecOps|DevSecOps]] 도입 사례.
|
||||
- **Contradictions/Notes:** 자동화 도구는 빠르고 일관된 스캔을 보장하지만, 코드의 비즈니스 의도나 아키텍처적 맥락(Context Blindness)을 파악하지 못해 최대 30~60%의 높은 오탐률(False Positives)을 낼 수 있으며 실제 취약점의 약 22%가량을 놓칠 수 있으므로 아키텍처 및 고위험 영역에 대한 인간의 검토가 반드시 병행되어야 한다 [27, 41].
|
||||
### 매 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.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
### 매 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.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### 매 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]}]
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### 매 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
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 매 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
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
# 매 PR 의 의 의 의 의 fail 의 의 의 의:
|
||||
# - new code coverage < 80%
|
||||
# - new bugs > 0
|
||||
# - new vulnerabilities > 0
|
||||
# - new code smells > 5
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### 매 Mutation testing (StrykerJS)
|
||||
```json
|
||||
{
|
||||
"packageManager": "pnpm",
|
||||
"testRunner": "vitest",
|
||||
"coverageAnalysis": "perTest",
|
||||
"thresholds": { "high": 80, "low": 60, "break": 50 }
|
||||
}
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### 매 Performance budget (Lighthouse CI)
|
||||
```json
|
||||
{
|
||||
"ci": {
|
||||
"collect": { "url": ["https://staging.example.com"] },
|
||||
"assert": {
|
||||
"assertions": {
|
||||
"categories:performance": ["error", { "minScore": 0.9 }],
|
||||
"interactive": ["error", { "maxNumericValue": 3000 }]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### 매 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
|
||||
- 부모: [[CI/CD]] · [[DevOps]]
|
||||
- 변형: [[자동화된 코드 리뷰]] · [[정적 분석]] · [[Test Automation]]
|
||||
- 응용: [[SonarQube]] · [[Semgrep]] · [[GitHub Actions]] · [[Claude Code Action]]
|
||||
- Adjacent: [[Code Quality Metrics]] · [[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 |
|
||||
|
||||
Reference in New Issue
Block a user