-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add static analysis and formatting checks to the CI pipeline to maintain code quality and consistency. Currently, there are no automated linting or formatting gates.
Tools to Add
1. Clippy (Rust Linter)
Catches common mistakes, suggests improvements, and enforces Rust best practices.
cargo clippy --all-targets --all-features -- -D warnings2. Rustfmt (Code Formatter)
Ensures consistent code formatting across the project.
cargo fmt --check3. Cargo Audit (Optional - Security)
Checks dependencies for known security vulnerabilities.
cargo auditProposed CI Configuration
Add to .github/workflows/build-cicd.yaml:
jobs:
lint:
name: Lint and Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: rustfmt, clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Check for security vulnerabilities
run: |
cargo install cargo-audit
cargo audit
test:
needs: lint # Run tests only if lint passes
# ... test configuration
build:
needs: test # Build only if tests pass
# ... build configurationClippy Configuration
Create clippy.toml in project root for custom lint configuration:
# clippy.toml
avoid-breaking-exported-api = falseOr configure via Cargo.toml:
[lints.clippy]
pedantic = "warn"
nursery = "warn"
unwrap_used = "warn"
expect_used = "warn"Rustfmt Configuration
Create rustfmt.toml for consistent formatting:
# rustfmt.toml
edition = "2021"
max_width = 100
tab_spaces = 4
use_small_heuristics = "Default"Acceptance Criteria
-
cargo fmt --checkruns in CI -
cargo clippyruns in CI with-D warnings(treat warnings as errors) - Lint job runs before test job
- Failed lint checks block PR merge
-
rustfmt.tomlcreated with project formatting standards - Existing code passes all checks (fix any existing issues first)
- Optional:
cargo auditfor security checks
Pre-Implementation Steps
Before enabling these checks in CI, fix any existing issues:
# Fix formatting
cargo fmt --all
# Check for clippy warnings and fix them
cargo clippy --all-targets --all-features
# Check for security vulnerabilities
cargo auditBenefits
- Consistency: All code follows same formatting standards
- Quality: Clippy catches common bugs and anti-patterns
- Security: Audit catches vulnerable dependencies
- Faster Reviews: No need to comment on style issues in PRs
- Learning: Clippy suggestions help developers learn Rust idioms
Priority
Medium - Important for code quality but can be added after core testing is in place.
Related Issues
- Add cargo test step to CI pipeline #20 - Add cargo test to CI pipeline (this builds on that)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request