code-reviewer
TypeScript、JavaScript、Python、Go、Swift、Kotlin 的代码审查自动化。分析 PR 的复杂性和风险,检查代码质量是否存在 SOLID 违规和代码异味,生成审核报告。在审查拉取请求、分析代码质量、识别问题、生成审查清单时使用。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:alirezarezvani~cs-code-reviewercURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Aalirezarezvani~cs-code-reviewer/file -o cs-code-reviewer.mdGit 仓库获取源码
git clone https://github.com/openclaw/skills/commit/a9b74e0be9c4d36210a77e2e7ae38c081e75fb1a# Code Reviewer Automated code review tools for analyzing pull requests, detecting code quality issues, and generating review reports. --- ## Table of Contents - [Tools](#tools) - [PR Analyzer](#pr-analyzer) - [Code Quality Checker](#code-quality-checker) - [Review Report Generator](#review-report-generator) - [Reference Guides](#reference-guides) - [Languages Supported](#languages-supported) --- ## Tools ### PR Analyzer Analyzes git diff between branches to assess review complexity and identify risks. ```bash # Analyze current branch against main python scripts/pr_analyzer.py /path/to/repo # Compare specific branches python scripts/pr_analyzer.py . --base main --head feature-branch # 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 --- ### Code Quality Checker Analyzes source code for structural issues, code smells, and SOLID violations. ```bash # Analyze a directory python scripts/code_quality_checker.py /path/to/code # Analyze specific language python scripts/code_quality_checker.py . --language python # 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 | --- ### Review Report Generator Combines PR analysis and code quality findings into structured review reports. ```bash # Generate report for current repo python scripts/review_report_generator.py /path/to/repo # Markdown output python scripts/review_report_generator.py . --format markdown --output review.md # Use pre-computed analyses python scripts/review_report_generator.py . \ --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 | --- ## Reference Guides ### Code Review Checklist `references/code_review_checklist.md` Systematic 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 ### Coding Standards `references/coding_standards.md` Language-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) ### Common Antipatterns `references/common_antipatterns.md` Antipattern 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) --- ## Languages Supported | Language | Extensions | |----------|------------| | Python | `.py` | | TypeScript | `.ts`, `.tsx` | | JavaScript | `.js`, `.jsx`, `.mjs` | | Go | `.go` | | Swift | `.swift` | | Kotlin | `.kt`, `.kts` | --- ## 中文说明 # 代码审查器(Code Reviewer) 用于分析拉取请求、检测代码质量问题并生成审查报告的自动化代码审查工具。 --- ## 目录 - [Tools](#tools) - [PR Analyzer](#pr-analyzer) - [Code Quality Checker](#code-quality-checker) - [Review Report Generator](#review-report-generator) - [Reference Guides](#reference-guides) - [Languages Supported](#languages-supported) --- ## 工具 ### PR 分析器(PR Analyzer) 分析分支之间的 git diff,以评估审查复杂度并识别风险。 ```bash # Analyze current branch against main python scripts/pr_analyzer.py /path/to/repo # Compare specific branches python scripts/pr_analyzer.py . --base main --head feature-branch # JSON output for integration python scripts/pr_analyzer.py /path/to/repo --json ``` **它检测的内容:** - 硬编码的密钥(密码、API 密钥、令牌) - SQL 注入模式(查询中的字符串拼接) - 调试语句(debugger、console.log) - 禁用的 ESLint 规则 - TypeScript `any` 类型 - TODO/FIXME 注释 **输出包含:** - 复杂度评分(1-10) - 风险分类(critical、high、medium、low) - 审查顺序的文件优先级排序 - 提交消息验证 --- ### 代码质量检查器(Code Quality Checker) 分析源代码中的结构性问题、代码异味和 SOLID 违规。 ```bash # Analyze a directory python scripts/code_quality_checker.py /path/to/code # Analyze specific language python scripts/code_quality_checker.py . --language python # JSON output python scripts/code_quality_checker.py /path/to/code --json ``` **它检测的内容:** - 过长的函数(>50 行) - 过大的文件(>500 行) - 上帝类(>20 个方法) - 深层嵌套(>4 层) - 参数过多(>5 个) - 高圈复杂度 - 缺少错误处理 - 未使用的导入 - 魔法数字 **阈值:** | 问题 | 阈值 | |-------|-----------| | 过长的函数 | >50 行 | | 过大的文件 | >500 行 | | 上帝类 | >20 个方法 | | 参数过多 | >5 个 | | 深层嵌套 | >4 层 | | 高复杂度 | >10 个分支 | --- ### 审查报告生成器(Review Report Generator) 将 PR 分析和代码质量发现合并为结构化的审查报告。 ```bash # Generate report for current repo python scripts/review_report_generator.py /path/to/repo # Markdown output python scripts/review_report_generator.py . --format markdown --output review.md # Use pre-computed analyses python scripts/review_report_generator.py . \ --pr-analysis pr_results.json \ --quality-analysis quality_results.json ``` **报告包含:** - 审查结论(approve、request changes、block) - 评分(0-100) - 优先级排序的行动项 - 按严重程度划分的问题摘要 - 建议的审查顺序 **结论:** | 评分 | 结论 | |-------|---------| | 90+ 且无 high 级别问题 | Approve | | 75+ 且 ≤2 个 high 级别问题 | Approve with suggestions | | 50-74 | Request changes | | <50 或存在 critical 问题 | Block | --- ## 参考指南 ### 代码审查清单 `references/code_review_checklist.md` 系统化清单,涵盖: - 审查前检查(构建、测试、PR 规范) - 正确性(逻辑、数据处理、错误处理) - 安全性(输入验证、注入防护) - 性能(效率、缓存、可扩展性) - 可维护性(代码质量、命名、结构) - 测试(覆盖率、质量、模拟) - 语言专用检查 ### 编码标准 `references/coding_standards.md` 语言专用标准,针对: - TypeScript(类型注解、空值安全、async/await) - JavaScript(声明、模式、模块) - Python(类型提示、异常、类设计) - Go(错误处理、结构体、并发) - Swift(可选值、协议、错误) - Kotlin(空值安全、数据类、协程) ### 常见反模式 `references/common_antipatterns.md` 带示例和修复方法的反模式目录: - 结构性(上帝类、长方法、深层嵌套) - 逻辑(布尔盲点、字符串类型化代码) - 安全性(SQL 注入、硬编码凭据) - 性能(N+1 查询、无界集合) - 测试(重复、测试实现细节) - 异步(游离的 promise、回调地狱) --- ## 支持的语言 | 语言 | 扩展名 | |----------|------------| | Python | `.py` | | TypeScript | `.ts`、`.tsx` | | JavaScript | `.js`、`.jsx`、`.mjs` | | Go | `.go` | | Swift | `.swift` | | Kotlin | `.kt`、`.kts` |