-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add a flag to exit with a non-zero status code on warnings #12300
Comments
Using There is a proposal on the cargo side to add a flag for this - rust-lang/cargo#8424 |
@Alexendoo, I didn't know that would work with Clippy warnings. Thanks! This is a good solution for CI but as it's a change to the rustc flags, it requires recompiling all dependencies, which is kind of unworkable for a pre-commit check. It sounds like the Cargo flag is the proposed solution already though, and reading through it, I get the impression it's intended to only apply to local crates, not dependencies, so I think it will address the above issue. Do you think this issue should be closed, then, and converted to a comment on the Cargo issue? |
You could try Yeah the cargo issue would be the place to look at for a solution that works everywhere in cargo, but I think that should suit your needs on the clippy side of things. As an aside [workspace.lints.clippy]
pedantic = { level = "warn", priority = -1 }
# disable some pedantic warnings which feel a little too pedantic
doc_markdown = "allow"
missing_errors_doc = "allow"
# ... |
Description
We can now configure the various levels of each lint option in Cargo.toml. I currently have one that looks like this:
I want to run Clippy in pre-commit checks and CI too, and in these situations, I want it to fail (exit with a non-zero status code) if any warnings are encountered.
Currently I have two ways of doing this:
sed
to rewrite Cargo.toml, replacing"warn"
with"deny"
, orNeither of these seem great. Using
sed
is error-prone, especially when running it locally in a pre-commit hook, and if I use flags, I have to re-specify all of the "allow" lints, which means I probably have to generate the command-line arguments programmatically.I would like a command-line argument that tells Clippy to fail on warnings instead. I suggest
--exit-with-failure-on-warnings
, though you may prefer something more terse.I am happy to attempt to work on this feature myself, but I would like to discuss it to ensure that the maintainers of Clippy agree in principle first.
If I am missing an obvious way to achieve this, please let me know!
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: