What Coding Standards and Style Guide Does the Brush Renderer Follow?
Brush enforces strict Rust coding standards through automated rustfmt formatting, comprehensive Clippy linting with workspace-wide configuration, and CI checks that treat all warnings as errors.
Brush is an open-source Gaussian splatting renderer written in Rust. The project maintains reproducible code quality through a combination of automated tooling and explicit lint configurations defined in the workspace root.
Automated Formatting with rustfmt
All source files in the repository must adhere to the official Rust style guide enforced by rustfmt.
CI Enforcement
The GitHub Actions workflow defined in .github/workflows/ci.yml automatically validates formatting on every push and pull request. The pipeline uses the actions-rs/toolchain action with the rustfmt component enabled, then runs cargo fmt -- --check to detect any deviations.
# .github/workflows/ci.yml (excerpt)
- name: rustfmt
uses: actions-rs/toolchain@v1
with:
component: rustfmt
- run: cargo fmt -- --check # Fails if any file is not properly formatted
Version Control Integration
The .gitignore file explicitly excludes rustfmt backup files (*~), confirming that automatic formatting is an integrated part of the development workflow rather than an optional step.
Strict Clippy Linting Configuration
Beyond formatting, Brush employs Clippy with strict rules that elevate warnings to errors.
Workspace-Level Lint Rules
The project centralizes its lint configuration in the root Cargo.toml. The [workspace.lints.clippy] table (lines 54-71) defines specific severity levels for individual lints, allowing fine-grained control over the codebase:
# Cargo.toml (excerpt)
[workspace.lints.clippy]
as_ptr_cast_mut = "warn"
await_holding_lock = "warn"
# ... additional lints
too_many_arguments = "allow" # Large GPU kernels need many parameters
large_include_file = "warn"
Additionally, general Rust lints are configured in lines 43-53 of Cargo.toml, creating a comprehensive rule set that catches potential bugs while permitting legitimate architectural patterns.
CI Pipeline Strictness
The workflow runs cargo clippy -- -D warnings, converting any Clippy warning into a build failure. This ensures that all merged code meets the project's quality standards without exception.
Local Exceptions and Documentation
While maintaining strict standards, the project permits documented exceptions for performance-critical code paths.
Selective Allow Attributes
Individual functions that legitimately violate specific lints—such as GPU kernels requiring many parameters—annotate the exception locally using #[allow(...)]. For example, in crates/brush-render/src/kernels/rasterize.rs, the rasterize_backwards function uses:
// In a GPU kernel where many arguments are unavoidable
#[allow(clippy::too_many_arguments)]
pub fn rasterize_backwards(
device: &wgpu::Device,
queue: &wgpu::Queue,
// … many more parameters …
) {
// kernel implementation …
}
This approach maintains clean code in general while explicitly documenting architectural necessities where strict linting would otherwise hinder performance optimization.
Rust Edition and Dependency Management
Brush targets the 2024 Rust edition, leveraging the latest language features and idiomatic patterns. The workspace Cargo.toml explicitly pins dependencies such as clap, tracing, and wgpu with specific version numbers, ensuring reproducible builds and consistent behavior across development environments.
Summary
- Automatic formatting: All Rust files must pass
rustfmtverification enforced in.github/workflows/ci.yml. - Comprehensive linting: The project configures specific Clippy rules in
Cargo.toml(lines 54-71) and runscargo clippy -- -D warningsin CI. - Documented exceptions: Performance-critical code uses
#[allow(clippy::...)]attributes, such as incrates/brush-render/src/kernels/rasterize.rs, to override specific lints locally. - Modern standards: Brush uses the 2024 Rust edition with pinned dependencies for reproducibility.
Frequently Asked Questions
What happens if my code doesn't match the Brush coding standards?
The CI pipeline will reject your pull request. You must run cargo fmt locally to fix formatting and resolve any Clippy warnings before submission, as the workflow treats all warnings as errors.
Why does Brush allow too_many_arguments for some functions?
GPU kernels and rendering functions often legitimately require many parameters to interface with graphics hardware efficiently. The project explicitly sets too_many_arguments = "allow" in Cargo.toml and uses local #[allow] attributes to avoid false positives while maintaining strict standards elsewhere.
Can I disable Clippy warnings locally in Brush?
You can use #[allow(clippy::lint_name)] attributes to disable specific warnings, but this should be reserved for cases where the lint conflicts with performance requirements or external API constraints. All exceptions should be documented and intentional, as seen in the kernel code.
Which Rust edition does Brush use?
Brush uses the 2024 Rust edition as defined in the workspace Cargo.toml, ensuring access to the latest language features, compiler improvements, and standard library updates.
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 →