Open
Description
Description
There are almost 50 Clippy configuration parameters. Most of them are likely unused by the users, in part because users do not know about them. I would like to propose a simple method to improve config param visibility: all lints should print a note, just once, in its output if the lint's behavior can be changed by a config parameter. The note should not be printed if the config param is already used. This approach would address some concerns from #9787
Note that the current config parser resolves defaults early on, so the lint doesn't know whether the config value is not set, or if it is set to the same value as default. We may want to introduce an additional flag for this in the future.
Example
span_lint_and_then(
cx,
DBG_MACRO,
macro_call.span,
"`dbg!` macro is intended as a debugging tool",
|diag| {
diag.span_suggestion(
macro_call.span,
"ensure to avoid having uses of it in version control",
suggestion,
applicability,
);
// ######################################
// ######### Add this new code #########
// ######################################
if !self.allow_dbg_in_tests {
// Improve lint config discoverability
diag.note_once(
"this lint can ignore test functions if \
`allow-dbg-in-tests = true` is added in the `clippy.toml` file",
);
}
},
);