rust-clippy
rust-clippy copied to clipboard
lints to disable in tests
trafficstars
Description
In Arti have things like the following:
#[cfg(test)]
mod test {
// @@ begin test lint list maintained by maint/add_warning @@
#![allow(clippy::bool_assert_comparison)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::dbg_macro)]
#![allow(clippy::mixed_attributes_style)]
#![allow(clippy::print_stderr)]
#![allow(clippy::print_stdout)]
#![allow(clippy::single_char_pattern)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::unchecked_duration_subtraction)]
#![allow(clippy::useless_vec)]
#![allow(clippy::needless_pass_by_value)]
//! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
// TODO add this next lint to maint/add_warning, for all tests
#![allow(clippy::iter_overeager_cloned)]
Our maint/add_warning is a Python script that keeps the (currently) 236 copies of this lint block in sync across our 61 crates.
It would be nice if there were a way to systematically and centrally disable these lints for all our tests. Probably, many of them should be disabled by default.
(@llogiq suggested I should file this ticket)
Version
No response
Additional Labels
No response
Thank you!
Finally I got around to looking into your list. I found that most lints will already ignore test code if configured so:
dbg_macrohas an allow-dbg-in-tests configuration. If you set that totruein yourclippy.toml, you can remove that lint from your list globally.- allow-print-in-tests
=truetakes care of bothprint_stdoutandprint_stderr. single_char_patternhas been demoted topedanticanyway, so it won't be linted at all unless you explicitly activate it.- allow-unwrap-in-tests makes
unwrap_usedignore tests - I just pushed #12725 to implement the same configuration option for
useless_vec
I'll have a look at the other lints when I find a few spare minutes.