Skip to content

Clippy Integration #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smklein opened this issue Apr 15, 2020 · 8 comments
Closed

Clippy Integration #304

smklein opened this issue Apr 15, 2020 · 8 comments
Assignees

Comments

@smklein
Copy link
Contributor

smklein commented Apr 15, 2020

Hey all, this is more of a feature request than a bug. If discussion would be better served outside a Github issue, lemme know, happy to relocate the conversation.

TL;DR: I have a project depending on rules_rust, and I'd like to be able to use clippy for linting produced libraries, binaries and tests.

It isn't immediately clear what would be the best way to go about doing this integration.

  • Given the precedent set by rust_doc, would clippy targets be best implemented as a rust_lint target, listing all crates as dependencies?
  • "clippy-driver" appears to be a non-Cargo mechanism for invoking clippy. Is there a similar target already ya'll would recommend taking a look at for "taking a Cargo command, and running it without Cargo"?

Happy to help contribute here, but I wanted to be oriented correctly before trying anything out :P

@mfarrugi
Copy link
Collaborator

mfarrugi commented Apr 15, 2020 via email

@damienmg
Copy link
Collaborator

Implementing it as a rule seems to me like a better approach. The rule itself might use some aspect to collect the sources but this does not seems correct for me to call Bazel with a special command-line for doing those clippy test, although this is more a UI question than an implementation one.

@smklein
Copy link
Contributor Author

smklein commented Jun 10, 2020

I managed to implement a clang-tidy aspect for C++ code in a private repo, so I think I have a better understanding of how this would work.

I'm finding myself needing to reach into rust/private/rustc.bzl to access CrateInfo, among other things.

@damienmg , would you be okay with me attempting the aspect approach? From a usability perspective on a large codebase, I find aspects to be significantly more convenient.

@damienmg
Copy link
Collaborator

@smklein : I don't have an issue with using aspect, I am just saying that the UI itself I find it more logical to be a separate rules (that would then use an aspect to execute the needed action on the build graph). Is that the approach you were considering?

@smklein
Copy link
Contributor Author

smklein commented Jun 10, 2020

I admittedly don't really need to make much use of the aspect propagation, the real thing I want to be able to do is the following:

bazel build --aspects=@rules_rust//rust:clippy.bzl%clippy_aspect --output_groups=clippy_checks //...

And to be able to dynamically run clippy across portions of a Bazel-oriented Rust workspace

@damienmg
Copy link
Collaborator

That's fine for me :)

@smklein smklein self-assigned this Jun 11, 2020
@smklein
Copy link
Contributor Author

smklein commented Jun 11, 2020

I have a work-in-progress solution here, which required much more cleanup.

Couple notes so far:

  • clippy-driver needs to be tightly coupled with rustc, so this causes some changes in how rustc is downloaded / extracted. As a result, the version of clippy is identical to the version of rust, since they'll be extracted from the same tarball.
  • To get a version of clippy-driver which works, I think I'm going to need to force a revision bump past 1.39.0. On that previous version, command line parsing was throwing "unrecognized lint' errors, but on 1.44.0, the driver seems content.

@smklein
Copy link
Contributor Author

smklein commented Jun 17, 2020

as of #339 , this is done!

@smklein smklein closed this as completed Jun 17, 2020
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

No branches or pull requests

3 participants