Skip to content

[Feature Request]: Lint Configuration inlined in the attribute macro. #10351

@GilShoshan94

Description

@GilShoshan94

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 named clippy.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:

// # lib.rs

//! My demo library.

// rustc lints
#![forbid(unsafe_code)]
#![deny(non_ascii_idents, unreachable_pub)]
#![warn(rust_2018_idioms)

// clippy lints
#![warn(
    clippy::pedantic, 
    clippy::cognitive_complexity(cognitive_complexity_threshold=30),
    clippy::branches_sharing_code,
)]

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions