Skip to content

Conversation

@blorente
Copy link

@blorente blorente commented Dec 5, 2025

Adds clippy support to rules_lint, which is part of #385. It does not support --fix yet, as there are some complications with applying the patches generated by rules_rust.

Caveats:

  • fix doesn't work.
  • The machine outputs are in in clippy's native JSON, not SARIF. We could use cargo-sarif to transform it, but we haven't for now.
  • We treat all clippy warnings as errors. This is because rules_rust will fail the entire execution if there's even one error, so we need to limit the reports to just warnings so that we can continue the target execution and generate useful output files. Because we limit all errors to warnings, we must consider every warning as an error.

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): Only if they were depending on rules_rust before, it may change their MODULE.lock resolution.
  • Suggested release notes appear below: yes/no

Test plan

  • New test cases added
  • Some of the cases are manual: cd examples && bazel test //test:clippy_ok_binary_with_bad_dep //test:clippy_bad_binary //test:clippy_bad_library

@CLAassistant
Copy link

CLAassistant commented Dec 5, 2025

CLA assistant check
All committers have signed the CLA.

@aspect-workflows
Copy link

aspect-workflows bot commented Dec 5, 2025

Test

All tests were cache hits

5 tests (100.0%) were fully cached saving 2s.


Test

example

8 test targets passed

Targets
//tools/format:format_test_HTML_Jinja_with_djlint [k8-fastbuild]3s
//tools/format:format_test_JavaScript_with_prettier [k8-fastbuild]11s
//tools/format:format_test_Markdown_with_prettier [k8-fastbuild]1s
//tools/format:format_test_Protocol_Buffer_with_buf [k8-fastbuild]515ms
//tools/format:format_test_Python_with_ruff [k8-fastbuild]805ms
//tools/format:format_test_SQL_with_prettier [k8-fastbuild]2s
//tools/format:format_test_Scala_with_scalafmt [k8-fastbuild]6s
//tools/format:format_test_Starlark_with_buildifier [k8-fastbuild]269ms

Total test execution time was 24s. 37 tests (82.2%) were fully cached saving 14s.


Test (WORKSPACE) (Test)

example

⚠️ Buildkite build #543 failed.

@@jq.bzl//:package_metadata failed to build

error loading package '@@jq.bzl//': Unable to find package for
@@package_metadata//rules:package_metadata.bzl: The repository '@@package_metadata' could not be resolved:
Repository '@@package_metadata' is not defined.

💡 To reproduce the build failures, run

bazel build @@jq.bzl//:package_metadata

@blorente blorente marked this pull request as ready for review December 5, 2025 16:16
lint/clippy.bzl Outdated
Typical usage:
First, install `rules_rust` into your repository: https://bazelbuild.github.io/rules_rust/. For instance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it require some minimum version of rules_rust to pick up your changes? would be good to document

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it needs 0.67.0. Added a comment.

Copy link
Member

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some initial comments between meetings - awesome!

If there is a success marker but the output is not empty, we mark it as a failure.
If there is no success marker, the action has failed anyway.
Please note that all clippy warnings are considered failures.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a TODO or "watch issue 385 for updates" here too right? It's not desirable behavior?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, added a comment.

@blorente
Copy link
Author

blorente commented Dec 5, 2025

I am not sure how, but that buildkite build is failing on this PR, but also failing on my local checkout of main:

➜ git show --stat | head -n 5                     
commit 837bfd82dd11e6c3125ec3a0c87970d8f4fbf30d
Author: Alex Eagle <alex@aspect.dev>
Date:   Fri Dec 5 10:12:48 2025 -0800

    fix: remove dep on aspect_bazel_lib (#668)

➜ (cd example && bqb @jq.bzl//... --noenable_bzlmod)
ERROR: error loading package under directory '': error loading package '@@jq.bzl//': Unable to find package for @@package_metadata//rules:package_metadata.bzl: The repository '@@package_metadata' could not be resolved: Repository '@@package_metadata' is not defined.

@alexeagle do you know why it might have passed on your PR #668?

)
_marker_to_exit_code(ctx, machine_success_indicator, outputs.machine.out, outputs.machine.exit_code)

# FIXME: Rustc only gives us JSON output, which we can't turn into SARIF yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants