rust-lint

star 27

Rust code quality check - Use Clippy and Rustfmt to ensure Rust code standards and performance optimization

y1feng200156 By y1feng200156 schedule Updated 2/10/2026

name: rust-lint description: Rust code quality check - Use Clippy and Rustfmt to ensure Rust code standards and performance optimization

Rust Lint Skill

๐Ÿ“‹ Overview

Use Rust official toolchain to check code quality:

  • Clippy: Smart code checks (450+ rules)
  • Rustfmt: Code formatting

๐Ÿ”ง Prerequisites

Tool Min Version Installation
Rust 1.70+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Clippy - rustup component add clippy
Rustfmt - rustup component add rustfmt

๐Ÿš€ Usage

Run Clippy:

.\.agent\skills\rust-lint\scripts\lint.ps1

Auto-fix:

.\.agent\skills\rust-lint\scripts\lint.ps1 -Fix

Format code:

.\.agent\skills\rust-lint\scripts\format.ps1

๐ŸŽฏ What It Checks

Performance Optimization

  • โœ… Avoid unnecessary clones
  • โœ… Use iterators instead of loops
  • โœ… String handling optimization
  • โœ… Collection operation efficiency

Security

  • โœ… Unused unsafe code
  • โœ… Integer overflow detection
  • โœ… Null pointer dereference
  • โœ… Lifetime issues

Idiomatic Rust

  • โœ… Pattern matching recommendations
  • โœ… Option/Result usage
  • โœ… Error handling best practices
  • โœ… Trait implementation suggestions

๐Ÿ“Š Output Example

๐Ÿฆ€ Rust Lint - Checking project...

warning: unnecessary use of `clone`
  --> src/main.rs:15:18
   |
15 |     let data = items.clone();
   |                      ^^^^^^^^ help: remove this
   |
   = note: `#[warn(clippy::unnecessary_clone)]` on by default

error: indexing may panic
  --> src/lib.rs:42:13
   |
42 |     let x = arr[5];
   |             ^^^^^^
   |
   = help: consider using `.get()` or `.get_mut()`

๐Ÿ“Š Results:
   โŒ Errors: 1
   โš ๏ธ  Warnings: 3

โš™๏ธ Configuration

Create clippy.toml:

cognitive-complexity-threshold = 30
too-many-arguments-threshold = 8

disallowed-methods = [
    "std::env::set_var",  # Unsafe environment variable setting
]

# Allowed lints
allow = [
    "clippy::module_name_repetitions",
]

# Warning level lints
warn = [
    "clippy::pedantic",
    "clippy::nursery",
]

# Denied lints
deny = [
    "clippy::unwrap_used",
    "clippy::expect_used",
]

Create rustfmt.toml:

max_width = 100
indent_style = "Block"
use_small_heuristics = "Default"
imports_granularity = "Crate"

๐Ÿ”— Related Resources

Install via CLI
npx skills add https://github.com/y1feng200156/ham-study --skill rust-lint
Repository Details
star Stars 27
call_split Forks 5
navigation Branch main
article Path SKILL.md
More from Creator
y1feng200156
y1feng200156 Explore all skills →