DR-006-Infra: Clippy Integration via rules_lint#
Date: 2026-01-19
Clippy Integration via rules_lint
|
status: accepted
|
||||
1. Context / Problem#
S-CORE needs a consistent, Bazel-native way to run Rust Clippy across modules. We initially aligned on rules_rust for Clippy integration, but rules_lint added native Clippy support while that work was ongoing. We must choose one approach to reduce divergence and keep lint workflows maintainable.
Key constraints:
Avoid running Clippy across the entire tree by default.
Avoid maintaining long, manual target lists.
Keep lint rules centralized and versioned.
Allow CI-friendly lint runs without additional tooling requirements.
2. Decision#
We adopt rules_lint for Clippy integration in S-CORE modules.
3. Rationale#
rules_lint fits better with the linting workflow:
It is designed for linting (output groups, lint tests, lint-oriented UX).
It avoids whole-tree runs and manual target lists by linting only the build graph of requested targets.
Clippy support is released and tested, which reduces risk.
rules_rust remains a valid option, but it requires manual target enumeration for lint-only runs and is harder to scope for incremental linting.
4. Integration Approach#
Each module integrates Clippy through a rules_lint aspect:
Use the shared aspect from
@score_rust_policies//clippy:linters.bzl(repo-local aspects remain an option if needed).Reference the centralized Clippy configuration from the policies repo:
@score_rust_policies//clippy/strict:clippy.toml.Enable the aspect in
.bazelrcviabuild --aspects=...%clippyand request output groupsrules_lint_human(and optionallyrules_lint_machine).Skip linting for specific targets using the
no-linttag.For CI, add
--@aspect_rules_lint//lint:fail_on_violation=trueto fail on findings.Use
aspect_rules_lint>=2.0.0-rc0to supportfail_on_violationwith Clippy.
This keeps configuration and behavior consistent while allowing each module to scope linting to the targets it builds.
5. Consequences#
Clippy runs on the Rust targets in the build graph of the requested Bazel targets, not the whole repository by default.
Lint rules are centralized in
score_rust_policies, reducing duplication and drift.The Aspect CLI is not required for Clippy execution; standard
bazel buildworks.rules_lint uses Aspect telemetry; this can be disabled via repo environment variables if required by policy.
6. Future Considerations#
We may integrate the Aspect CLI in the future to enable the bazel lint command and
additional lint UX (interactive output, filtering, reporting). This is optional and
separate from the Bazel-based execution path.