/rust-review

2026-08-30 浏览 (1)

/rust-review

Lightweight Rust code review using clippy.

Usage

/rust-review [path]

Parameters

  • path (optional): Path to file or directory to review. Defaults to current directory.

What It Does

运行 cargo clippy 进行代码审查:

检查类型说明
clippy::correctness明确错误的代码
clippy::suspicious可疑代码
clippy::complexity过于复杂的代码
clippy::perf性能问题
clippy::style风格问题

Workflow

  1. 读取代码 - 分析目标文件/目录
  2. 运行 clippy - cargo clippy --message-format=json
  3. 分析结果 - 按严重程度分类
  4. 提供修复建议 - 代码示例

Example Output

Rust Code Review: src/lib.rs

Running clippy...

═══════════════════════════════════════════
Results: 3 issues found
═══════════════════════════════════════════

ERROR (1):
  src/lib.rs:42 [clippy::unwrap_used]
    → unwrap() called on Result
    → Fix: Use ? operator or handle error explicitly

WARNING (2):
  src/lib.rs:15 [clippy::needless_clone]
    → Clone is not needed here
    → Fix: Remove .clone()

  src/lib.rs:28 [clippy::manual_map]
    → Use Option::map instead of match
    → Fix: x.map(|v| v + 1)

═══════════════════════════════════════════

Clippy Configuration

项目可通过 clippy.tomlCargo.toml 配置 clippy:

# Cargo.toml
[lints.clippy]
unwrap_used = "deny"
expect_used = "warn"

NOT Included

以下检查不在 /rust-review 范围内:

检查原因替代命令
cargo fmt部分项目不支持手动运行
miri太重,需要 nightly/audit safety
cargo audit安全审计场景/audit security
lockbud专用并发审计/audit concurrency

Related Commands

  • /audit - 重量级安全审计(使用 os-checker)
  • /unsafe-check - 专注 unsafe 代码检查
  • /guideline - 查询编码规范

你可能感兴趣的文章

/crate-info

/docs Command

/skill-index

Create llms.txt from URLs

/rust-features

Achievement System

Update Crate Skill

/unsafe-check

AI Daily Report

Sync Crate Skills

  • 所属分类: AI
  • 本文标签: rust
  • 版权声明: 本文链接 https://seaxiang.com/blog/XglhSEh3