| Crates.io | cargo-quality |
| lib.rs | cargo-quality |
| version | 0.1.5 |
| created_at | 2025-11-25 02:30:43.157966+00 |
| updated_at | 2025-11-28 08:13:52.093476+00 |
| description | Professional Rust code quality analysis tool with hardcoded standards |
| homepage | https://github.com/RAprogramm/cargo-quality |
| repository | https://github.com/RAprogramm/cargo-quality |
| max_upload_size | |
| id | 1949099 |
| size | 10,462,400 |
Professional Rust code quality analysis tool with hardcoded standards.
cargo-quality is a command-line tool that enforces consistent code quality standards across Rust projects without requiring local configuration files. All quality rules are hardcoded in the binary, ensuring uniform formatting and analysis across your entire codebase and organization.
This tool is built on principles defined in RustManifest - a comprehensive Rust engineering standards template.
Modern Rust development lacks a unified, zero-configuration quality tool that:
Eliminates Configuration Sprawl - Projects accumulate .rustfmt.toml, .clippy.toml, and custom scripts, each requiring maintenance and synchronization across repositories.
Enforces Team Standards - Without a central tool, each developer interprets "good code" differently, leading to inconsistent code reviews and merge conflicts.
Provides Instant Feedback - Developers need immediate, actionable feedback on code quality without waiting for CI pipelines or manual reviews.
Bridges the Gap - While rustfmt handles formatting and clippy catches bugs, neither enforces higher-level architectural patterns like import organization or argument naming conventions.
cargo-quality embeds battle-tested standards from RustManifest directly into its binary:
This tool serves teams that value consistency, automation, and professional engineering practices over ad-hoc configurations.
RustManifest defines:
cargo-quality implements these standards as enforceable rules, making RustManifest principles executable and verifiable across your entire codebase.
--analyzer flagInstall from crates.io:
cargo install cargo-quality
# Setup shell completions (recommended)
cargo qual setup
Install from source:
git clone https://github.com/RAprogramm/cargo-quality
cd cargo-quality
cargo install --path .
# Setup shell completions (recommended)
cargo qual setup
After installation, set up tab completions:
# Automatic setup (recommended - detects your shell)
cargo qual setup
# Manual setup for specific shell
cargo qual completions fish > ~/.config/fish/completions/cargo.fish
cargo qual completions bash > ~/.local/share/bash-completion/completions/cargo-quality
cargo qual completions zsh > ~/.local/share/zsh/site-functions/_cargo-quality
Note: Completions will be available in new shell sessions. To use immediately, restart your shell or source the completion file.
# Check code quality (compact output by default)
cargo qual check src/
# Check with detailed output
cargo qual check --verbose src/
# Check specific analyzer only
cargo qual check -a inline_comments
# Preview fixes
cargo qual fix --dry-run
# Apply fixes from specific analyzer
cargo qual fix -a path_import
# Format with hardcoded standards
cargo qual fmt
# Display help
cargo qual help
Analyze code quality without modifying files.
cargo qual check [PATH] [--verbose] [--analyzer <NAME>] [--color]
Options:
--verbose, -v - Show detailed output for all files (every issue separately)--analyzer, -a <NAME> - Run specific analyzer only--color, -c - Enable colored output with syntax highlightingOutput Modes:
Compact Mode (Default) - Groups identical messages together with grid layout:
[empty_lines] - 42 issues [format_args] - 7 issues
──────────────────────────── ────────────────────────────
Empty line in function body... Use named format arguments...
src/report.rs → Lines: src/report.rs → Lines: 167
74, 78, 83, 91, 93, 98... src/differ/display.rs → Lines:
src/main.rs → Lines: 106, 116, 171, 183
49, 88, 102, 105, 113...
════════════════════════════ ════════════════════════════
Features:
Verbose Mode (--verbose flag) - Shows every issue separately with full details:
[empty_lines]
74:1 - Empty line in function body indicates untamed complexity
Fix:
78:1 - Empty line in function body indicates untamed complexity
Fix:
...
Colored Output (--color flag) - Syntax highlighting for better readability:
Selective Execution - Run specific analyzers:
# Run only inline comments analyzer
cargo qual check -a inline_comments
# Run only path import analyzer
cargo qual check -a path_import
Examples:
# Check with compact output (default)
cargo qual check src/
# Check with detailed output
cargo qual check --verbose .
# Check with colored output
cargo qual check --color src/
# Check only inline comments
cargo qual check -a inline_comments
Apply automatic quality fixes to your code.
cargo qual fix [PATH] [--dry-run] [--analyzer <NAME>]
Options:
--dry-run, -d - Preview changes without modifying files--analyzer, -a <NAME> - Apply fixes from specific analyzer onlyExamples:
# Preview all fixes
cargo qual fix --dry-run
# Apply all fixes
cargo qual fix src/
# Apply only path import fixes
cargo qual fix -a path_import
Format code using cargo +nightly fmt with hardcoded project standards.
cargo qual fmt [PATH]
This command uses the following hardcoded configuration:
max_width = 99trailing_comma = "Never"brace_style = "SameLineWhere"imports_granularity = "Crate"group_imports = "StdExternalCrate"struct_field_align_threshold = 20wrap_comments = trueformat_code_in_doc_comments = truereorder_imports = trueunstable_features = trueThe configuration is passed via command-line arguments and does not create or modify any .rustfmt.toml files.
Examples:
cargo qual fmt
cargo qual fmt src/
Format code according to quality analyzer rules.
cargo qual format [PATH]
Examples:
cargo qual format .
Visualize proposed changes before applying fixes.
cargo qual diff [PATH] [--summary] [--interactive] [--analyzer <NAME>] [--color]
Options:
--summary, -s - Show brief summary of changes per file--interactive, -i - Interactive mode to select which fixes to apply--analyzer, -a <NAME> - Show diff for specific analyzer only--color, -c - Enable colored output with syntax highlightingDisplay modes:
Examples:
# Full diff view
cargo qual diff src/
# Summary view
cargo qual diff --summary
# Interactive mode
cargo qual diff --interactive
# Show only path import changes
cargo qual diff -a path_import
# Colored output
cargo qual diff --color --summary
Output format:
Line 529
- std::fs::write(buffer, data);
+ use std::fs::write;
+ write(buffer, data);
Display detailed help with examples and usage patterns.
cargo qual help
Detects direct module path usage that should be moved to import statements.
Bad:
let content = std::fs::read_to_string("file.txt");
Good:
use std::fs::read_to_string;
let content = read_to_string("file.txt");
The analyzer correctly distinguishes between:
Vec::new)Option::Some)u32::MAX)Detects positional arguments in format macros and suggests named arguments.
Bad:
println!("Hello {}, you are {}", name, age);
Good:
println!("Hello {name}, you are {age}");
Detects empty lines inside function and method bodies that indicate untamed complexity. Based on principles from Empty Line Code Smell.
Bad:
fn process() {
let x = read();
let y = transform(x);
write(y);
}
Good:
fn process() {
let x = read();
let y = transform(x);
write(y);
}
When running cargo qual diff, empty lines are shown as a summary note:
Note: 3 empty lines will be removed from lines: 3, 5, 11
Detects inline comments (//) inside function and method bodies. According to professional documentation standards, all explanations should be in doc comments (///), specifically in the # Notes section with code context.
Bad:
fn calculate(x: i32, y: i32) -> i32 {
// Add the numbers
let sum = x + y;
// Multiply by 2
let result = sum * 2;
// Return final result
result
}
Good:
/// Calculate something
///
/// # Notes
///
/// - Add the numbers - `let sum = x + y;`
/// - Multiply by 2 - `let result = sum * 2;`
/// - Return final result - `result`
fn calculate(x: i32, y: i32) -> i32 {
let sum = x + y;
let result = sum * 2;
result
}
Important: This analyzer only detects issues and provides suggestions. It does not apply automatic fixes (Fix::None). Use cargo qual check -a inline_comments to see all inline comments that should be moved to doc blocks.
When running cargo qual check -a inline_comments, the output shows:
[inline_comments] - 3 issues
Inline comment found: "Add the numbers"
Move to doc block # Notes section:
/// - Add the numbers - `let sum = x + y;`
→ Lines: 2
Inline comment found: "Multiply by 2"
Move to doc block # Notes section:
/// - Multiply by 2 - `let result = sum * 2;`
→ Lines: 4
Run specific analyzers using the --analyzer or -a flag:
path_import - Path Import Analyzerformat_args - Format Args Analyzerempty_lines - Empty Lines Analyzerinline_comments - Inline Comments AnalyzerExample:
# Check only inline comments
cargo qual check -a inline_comments
# Fix only path imports
cargo qual fix -a path_import
# Show diff only for empty lines
cargo qual diff -a empty_lines
Typical development workflow:
cargo qual check src/
cargo qual fix --dry-run
cargo qual fix
cargo qual fmt
Use cargo-quality directly in your CI/CD pipelines:
name: Quality Check
on: [pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run cargo-quality
uses: RAprogramm/cargo-quality@v0
with:
path: 'src/'
fail_on_issues: 'true'
post_comment: 'true'
| Input | Description | Default |
|---|---|---|
path |
Path to analyze | src/ |
analyzer |
Specific analyzer to run | (all) |
fail_on_issues |
Fail if issues found | true |
post_comment |
Post results as PR comment | false |
update_comment |
Update existing comment | true |
| Output | Description |
|---|---|
total_issues |
Total number of issues found |
path_import_issues |
Issues from path_import analyzer |
format_args_issues |
Issues from format_args analyzer |
empty_lines_issues |
Issues from empty_lines analyzer |
inline_comments_issues |
Issues from inline_comments analyzer |
has_issues |
Whether any issues were found |
When post_comment: 'true' is set, the action posts a detailed report to your PR:
## cargo-quality report
> ⚠️ **5 issue(s) found** - Please review the details below
| Analyzer | Issues | Distribution |
|:---------|-------:|:-------------|
| `path_import` | 3 | `██████░░░░` |
| `format_args` | 2 | `████░░░░░░` |
| `empty_lines` | 0 | `░░░░░░░░░░` |
| `inline_comments` | 0 | `░░░░░░░░░░` |
| **Total** | **5** | |
📎 Commit abc1234 | 🚀 CI Run | 📖 Documentation
Features:
Run specific analyzer only:
- uses: RAprogramm/cargo-quality@v0
with:
analyzer: 'path_import'
fail_on_issues: 'false'
Use outputs in subsequent steps:
- uses: RAprogramm/cargo-quality@v0
id: quality
- name: Check results
if: steps.quality.outputs.has_issues == 'true'
run: echo "Found ${{ steps.quality.outputs.total_issues }} issues"
| Tag | Description |
|---|---|
@v0 |
Latest 0.x.x release (recommended) |
@v0.1.0 |
Specific version |
@v1 |
Latest 1.x.x release (when available) |
If you prefer manual installation:
name: Quality Check
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-quality
run: cargo install cargo-quality
- name: Check code quality
run: cargo qual check
- name: Format check
run: cargo qual fmt
Build from source:
cargo build --release
Run tests:
cargo test
Run benchmarks:
cargo bench
Check license compliance:
reuse lint
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Contributions are welcome. Please ensure:
This project is licensed under the MIT License. See the LICENSE file for details.
SPDX-License-Identifier: MIT