You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Also, if it is doable, the config can be renamed shorter, cognitive_complexity_threshold -> threshold, as it cannot be misinterpreted for another lint.)
Version
No response
Additional Labels
C-enhancement
The text was updated successfully, but these errors were encountered:
J-ZhengLi
added
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
and removed
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
labels
Apr 2, 2024
good idea, I saw @flip1995 made a comment addressing similar stuff here, but I like yours better (XD), which means rustc lints could also benefit from this.
The lint level attributes are not implemented by Clippy, but by rustc. So this change would have to be done in rustc. However, there is no such thing as a lint configuration, as far as the compiler/Clippy is concerned. You can only configure the tool. So each configuration is a 1-to-many relationship to lints, where N might be 1 (cog-comp). So conceptually you can't configure a single lint with a configuration. You can only configure the tool, in this case Clippy, to apply the configuration to all lints. Special casing some lints here would be a lot of work (upstream in rustc and in Clippy) for something I/we don't really want to support.
Also in the future you want to configure your global lints in the Cargo.toml file. Your Clippy [lint] configuration then goes into clippy.toml. Only a few configurations can be applied with an attribute.
Description
Hi,
Awsome tool that help me to be proeficient in Rust.
I am trying to use some of the new lint such as
clippy::cognitive_complexity
.I see it can be configured by
cognitive-complexity-threshold
.To my understanding, some lints can be tuned and they are listed here: Lint Configuration Options.
Unless I missunderstood, the only way to set those configurations is in a in a
TOML
file namedclippy.toml
or.clippy.toml
.I like to set all my lint configuration in my
lib.rs
/main.rs
in the attributes#![allow/warn/deny/forbid(...)]
at the beginnig of the file.It lets me see a nice overview of all my lints settings.
Is it possible for the configurable lints to have their config inlined in the attribute so we won't need an extra
clippy.toml
file ?I imagined something like:
#![warn(clippy::<lints>(<config1>=<value1>, <config2>=<value2>, ...))]
Example with
clippy::cognitive_complexity
:(Also, if it is doable, the config can be renamed shorter, cognitive_complexity_threshold -> threshold, as it cannot be misinterpreted for another lint.)
Version
No response
Additional Labels
C-enhancement
The text was updated successfully, but these errors were encountered: