code-reviewer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Reviewer
代码审查自动化工具
Automated code review tools for analyzing pull requests, detecting code quality issues, and generating review reports.
用于分析拉取请求(PR)、检测代码质量问题并生成审查报告的自动化代码审查工具。
Table of Contents
目录
Tools
工具
PR Analyzer
PR分析器
Analyzes git diff between branches to assess review complexity and identify risks.
bash
undefined分析分支间的git diff以评估审查复杂度并识别风险。
bash
undefinedAnalyze current branch against main
Analyze current branch against main
python scripts/pr_analyzer.py /path/to/repo
python scripts/pr_analyzer.py /path/to/repo
Compare specific branches
Compare specific branches
python scripts/pr_analyzer.py . --base main --head feature-branch
python scripts/pr_analyzer.py . --base main --head feature-branch
JSON output for integration
JSON output for integration
python scripts/pr_analyzer.py /path/to/repo --json
**What it detects:**
- Hardcoded secrets (passwords, API keys, tokens)
- SQL injection patterns (string concatenation in queries)
- Debug statements (debugger, console.log)
- ESLint rule disabling
- TypeScript `any` types
- TODO/FIXME comments
**Output includes:**
- Complexity score (1-10)
- Risk categorization (critical, high, medium, low)
- File prioritization for review order
- Commit message validation
---python scripts/pr_analyzer.py /path/to/repo --json
**检测内容包括:**
- 硬编码机密(密码、API密钥、令牌)
- SQL注入模式(查询中的字符串拼接)
- 调试语句(debugger、console.log)
- 禁用ESLint规则
- TypeScript `any` 类型
- TODO/FIXME注释
**输出内容包括:**
- 复杂度评分(1-10)
- 风险分类(严重、高、中、低)
- 按审查优先级排序的文件列表
- 提交信息验证
---Code Quality Checker
代码质量检查器
Analyzes source code for structural issues, code smells, and SOLID violations.
bash
undefined分析源代码中的结构问题、代码异味以及SOLID原则违反情况。
bash
undefinedAnalyze a directory
Analyze a directory
python scripts/code_quality_checker.py /path/to/code
python scripts/code_quality_checker.py /path/to/code
Analyze specific language
Analyze specific language
python scripts/code_quality_checker.py . --language python
python scripts/code_quality_checker.py . --language python
JSON output
JSON output
python scripts/code_quality_checker.py /path/to/code --json
**What it detects:**
- Long functions (>50 lines)
- Large files (>500 lines)
- God classes (>20 methods)
- Deep nesting (>4 levels)
- Too many parameters (>5)
- High cyclomatic complexity
- Missing error handling
- Unused imports
- Magic numbers
**Thresholds:**
| Issue | Threshold |
|-------|-----------|
| Long function | >50 lines |
| Large file | >500 lines |
| God class | >20 methods |
| Too many params | >5 |
| Deep nesting | >4 levels |
| High complexity | >10 branches |
---python scripts/code_quality_checker.py /path/to/code --json
**检测内容包括:**
- 过长函数(超过50行)
- 过大文件(超过500行)
- 上帝类(超过20个方法)
- 过深嵌套(超过4层)
- 参数过多(超过5个)
- 高圈复杂度
- 缺少错误处理
- 未使用的导入
- 魔法数值
**阈值:**
| 问题 | 阈值 |
|-------|-----------|
| 过长函数 | >50行 |
| 过大文件 | >500行 |
| 上帝类 | >20个方法 |
| 参数过多 | >5个 |
| 过深嵌套 | >4层 |
| 高复杂度 | >10个分支 |
---Review Report Generator
审查报告生成器
Combines PR analysis and code quality findings into structured review reports.
bash
undefined将PR分析结果与代码质量检测结果整合为结构化审查报告。
bash
undefinedGenerate report for current repo
Generate report for current repo
python scripts/review_report_generator.py /path/to/repo
python scripts/review_report_generator.py /path/to/repo
Markdown output
Markdown output
python scripts/review_report_generator.py . --format markdown --output review.md
python scripts/review_report_generator.py . --format markdown --output review.md
Use pre-computed analyses
Use pre-computed analyses
python scripts/review_report_generator.py .
--pr-analysis pr_results.json
--quality-analysis quality_results.json
--pr-analysis pr_results.json
--quality-analysis quality_results.json
**Report includes:**
- Review verdict (approve, request changes, block)
- Score (0-100)
- Prioritized action items
- Issue summary by severity
- Suggested review order
**Verdicts:**
| Score | Verdict |
|-------|---------|
| 90+ with no high issues | Approve |
| 75+ with ≤2 high issues | Approve with suggestions |
| 50-74 | Request changes |
| <50 or critical issues | Block |
---python scripts/review_report_generator.py .
--pr-analysis pr_results.json
--quality-analysis quality_results.json
--pr-analysis pr_results.json
--quality-analysis quality_results.json
**报告内容包括:**
- 审查结论(批准、请求修改、阻止合并)
- 评分(0-100)
- 按优先级排序的行动项
- 按严重程度分类的问题汇总
- 建议的审查顺序
**结论规则:**
| 评分 | 结论 |
|-------|---------|
| 90分以上且无高风险问题 | 批准 |
| 75分以上且高风险问题≤2个 | 附建议批准 |
| 50-74分 | 请求修改 |
| 低于50分或存在严重问题 | 阻止合并 |
---Reference Guides
参考指南
Code Review Checklist
代码审查清单
references/code_review_checklist.mdSystematic checklists covering:
- Pre-review checks (build, tests, PR hygiene)
- Correctness (logic, data handling, error handling)
- Security (input validation, injection prevention)
- Performance (efficiency, caching, scalability)
- Maintainability (code quality, naming, structure)
- Testing (coverage, quality, mocking)
- Language-specific checks
references/code_review_checklist.md包含系统性检查项:
- 审查前检查(构建、测试、PR规范性)
- 正确性(逻辑、数据处理、错误处理)
- 安全性(输入验证、注入防护)
- 性能(效率、缓存、可扩展性)
- 可维护性(代码质量、命名、结构)
- 测试(覆盖率、质量、模拟)
- 语言特定检查
Coding Standards
编码规范
references/coding_standards.mdLanguage-specific standards for:
- TypeScript (type annotations, null safety, async/await)
- JavaScript (declarations, patterns, modules)
- Python (type hints, exceptions, class design)
- Go (error handling, structs, concurrency)
- Swift (optionals, protocols, errors)
- Kotlin (null safety, data classes, coroutines)
references/coding_standards.md各语言专属规范:
- TypeScript(类型注解、空安全、async/await)
- JavaScript(声明方式、设计模式、模块)
- Python(类型提示、异常处理、类设计)
- Go(错误处理、结构体、并发)
- Swift(可选类型、协议、错误处理)
- Kotlin(空安全、数据类、协程)
Common Antipatterns
常见反模式
references/common_antipatterns.mdAntipattern catalog with examples and fixes:
- Structural (god class, long method, deep nesting)
- Logic (boolean blindness, stringly typed code)
- Security (SQL injection, hardcoded credentials)
- Performance (N+1 queries, unbounded collections)
- Testing (duplication, testing implementation)
- Async (floating promises, callback hell)
references/common_antipatterns.md包含示例与修复方案的反模式目录:
- 结构类(上帝类、过长方法、过深嵌套)
- 逻辑类(布尔盲、字符串类型化代码)
- 安全类(SQL注入、硬编码凭证)
- 性能类(N+1查询、无界集合)
- 测试类(重复代码、实现细节测试)
- 异步类(游离Promise、回调地狱)
Languages Supported
支持的语言
| Language | Extensions |
|---|---|
| Python | |
| TypeScript | |
| JavaScript | |
| Go | |
| Swift | |
| Kotlin | |
| 语言 | 扩展名 |
|---|---|
| Python | |
| TypeScript | |
| JavaScript | |
| Go | |
| Swift | |
| Kotlin | |