How to Check Code Formatting in OpenLogi: A Complete Verification Guide
To check code formatting in OpenLogi, run cargo fmt --all -- --check from the repository root to validate all workspace crates without modifying files.
OpenLogi is a Rust-based logistics platform where maintaining consistent code style is essential when contributing to its approximately 30 workspace crates. This guide explains how to check code formatting in OpenLogi using the standardized cargo fmt toolchain across three enforcement layers: local development, pre-commit hooks, and continuous integration.
Understanding OpenLogi's Formatting Architecture
The repository follows standard Rust formatting workflows powered by Rustfmt, ensuring consistent style across the entire codebase.
Workspace-Wide Configuration
OpenLogi organizes roughly 30 crates under a single workspace defined in Cargo.toml at the repository root. The formatting configuration respects workspace-wide rustfmt.toml settings (if present) and the edition defined in each crate's Cargo.toml. The rust-toolchain.toml file pins the Minimum Supported Rust Version (MSRV), guaranteeing that formatting behavior remains consistent across all development environments and CI runners.
Key Configuration Files
Several source files document and enforce the formatting pipeline:
docs/DEVELOPMENT.md(line 195) documents the local formatting command for developersAGENTS.md(line 102) defines the pre-commit hook configuration.claude/rules/ci.md(line 47) specifies the CIrustfmtjobrust-toolchain.tomlpins the Rust version for reproducible formattingCargo.tomllists all workspace members thatcargo fmt --alltraverses
How to Check Code Formatting Locally
Developers can verify formatting compliance before submitting changes using the standard Rust toolchain.
Prerequisites
Ensure the Rust toolchain is installed. The repository's rust-toolchain.toml pins the MSRV, ensuring your local cargo fmt version matches the project's requirements.
The Verification Command
From the repository root, execute:
cargo fmt --all -- --check
This command invokes rustfmt on every crate in the workspace. The --all flag ensures all workspace members are processed, while --check operates in read-only mode—it reports deviations without modifying files and exits with a non-zero status if any file requires formatting.
Fixing Formatting Issues
If the check reports violations, apply the formatter without the --check flag:
cargo fmt --all
After formatting, re-run the check command to confirm compliance:
cargo fmt --all -- --check
Automated Formatting Enforcement in OpenLogi
OpenLogi enforces formatting automatically at two critical checkpoints to prevent style violations from entering the codebase.
Pre-Commit Hooks
According to AGENTS.md (line 102), the repository utilizes a pre-commit hook described in the hook configuration. Every commit is automatically processed through cargo fmt, catching formatting issues before they enter the git history.
Continuous Integration Gate
The CI pipeline defined in .claude/rules/ci.md (line 47) includes a rustfmt job that executes:
cargo fmt --all -- --check
This job guarantees that all pushed code complies with the style guidelines before the merge gate is passed. Any formatting violations will fail the build, requiring the developer to fix the issues locally and push again.
Essential Formatting Commands for Developers
Use these commands during development to maintain code quality across the OpenLogi workspace:
# CI-style verification (read-only)
cargo fmt --all -- --check
# Auto-format entire workspace
cargo fmt --all
# Combine with linting for a single crate example
cargo clippy -p openlogi-core -- -D warnings
Summary
- Primary command: Use
cargo fmt --all -- --checkto verify formatting across all 30+ crates without modifying files - Configuration: Formatting respects
rustfmt.tomland the MSRV pinned inrust-toolchain.toml - Automation: Pre-commit hooks (defined in
AGENTS.md) and CI gates (.claude/rules/ci.md) enforce style automatically - Fixing issues: Run
cargo fmt --allto auto-correct violations, then re-verify with the check command - Documentation: Development workflows are documented in
docs/DEVELOPMENT.md(line 195)
Frequently Asked Questions
How do I check if my OpenLogi code follows the formatting standards?
Run cargo fmt --all -- --check from the repository root. This validates all workspace crates and exits with a non-zero status if any file violates the style guidelines, printing the paths of offending files without modifying them.
What should I do if the formatting check fails in CI?
Run cargo fmt --all locally to auto-format all files in the workspace, then commit and push the changes. The CI job defined in .claude/rules/ci.md executes the same check command, so local verification prevents pipeline failures.
Does OpenLogi use custom formatting rules?
OpenLogi follows standard Rustfmt conventions. While the repository may include a rustfmt.toml for workspace-wide preferences, the primary enforcement relies on the Rust toolchain version pinned in rust-toolchain.toml to ensure consistent behavior across environments.
Can I format just one crate instead of the entire workspace?
While cargo fmt --all processes the entire workspace, you can target specific packages using cargo fmt -p <package-name>. However, CI and pre-commit hooks require full workspace compliance, so verifying the entire workspace with --all is recommended before submitting changes.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →