Open eismont21 opened 3 weeks ago
There is some weirdness with rustfix, that it ignores lint levels set via console arguments. I believe you can go around that by using the RUSTFLAGS
environment value instead. Though, I would suggest to only run the normal clippy. Running it in the background and updating source files could be unexpected for users in your project.
Thank you for the suggestion. I implemented it by updating the command as follows:
RUSTFLAGS="-D warnings" cargo clippy --all-features --fix
Unfortunately, the hook still finishes successfully even when warnings are logged, allowing the push to proceed.
Description
I'm trying to integrate cargo clippy as part of my pre-commit hooks to enforce code quality in my project. The command I'm using is:
cargo clippy --all-features --fix -- -D warnings
Here's the behavior I'm aiming for:
The first scenario works as expected—when clippy successfully fixes issues, the push is aborted due to new changes in the codebase, which is great. However, in the second scenario, if clippy can't fix the warnings, I don't receive any errors, and the push goes through as if everything is fine, even though it isn't. I do see these warnings in the log, but the check finishes successfully without any errors, so the push isn’t aborted as it should be.
How to ensure that the pre-commit hook catches when clippy can't automatically fix warnings?
Version
Additional Labels
@rustbot label C-question