Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider configuring Clippy #848

Closed
vipentti opened this issue Feb 17, 2019 · 4 comments
Closed

Consider configuring Clippy #848

vipentti opened this issue Feb 17, 2019 · 4 comments

Comments

@vipentti
Copy link
Contributor

According to rust-lang/rust-clippy#configuration:

Some lints can be configured in a TOML file named clippy.toml or .clippy.toml. It contains a basic variable = value mapping eg.

We could consider adding Clippy configuration to allow running cargo clippy on rust-analyzer while developing without reporting large number of warnings that are not relevant to rust-analyzer.

For the lints that currently cannot be configured in a TOML file we can ignore those (allow those to report warnings) or add some "global" inner attributes that allow them.

I think ideally running cargo clippy on rust-analyzer should return no warnings / errors even if it means we allow some lints to pass. This could help people trying to contribute with creating more idiomatic solutions.

@matklad
Copy link
Member

matklad commented Feb 17, 2019

I personally don't use clippy much, because, while it does find a number of legit issues, it also tends to find a significant number of false-positives (examples) and blindly fixing those usually makes code worse. I am also not a fan of suppressing warnings on each individual expression/function, etc, as that also makes code less readable for trivial reasons.

Disabling lints in .toml sounds great to me! Is there some preconfigured set of lints with no false positives?

@vipentti
Copy link
Contributor Author

Looks like the actual Enabling/Disabling lints through the config is still pending according to rust-lang/rfcs#2476 (comment) and rust-lang/cargo#5034

I guess an alternative, since clippy allows passing lints as flags to cargo clippy e.g. cargo clippy -- -A clippy::lint_name, we could provide an alias or a set of flags in some document that would allow running the lints that rust-analyzer may be interested in.

It may even make sense to have cargo clippy -- -A clippy::all as the default and then having some explicit -D flags for denying particular types of lints.

@matklad
Copy link
Member

matklad commented Feb 18, 2019

I guess an alternative, since clippy allows passing lints as flags to cargo clippy e.g. cargo clippy -- -A clippy::lint_name, we could provide an alias or a set of flags in some document that would allow running the lints that rust-analyzer may be interested in.

We can add cargo lint command to the tools infra, the same way we added cargo format.

bors bot added a commit that referenced this issue Jun 4, 2019
1374: Implement `cargo lint` and fix some clippy errors r=alanhdu a=alanhdu

This creates a `cargo lint` command that runs clippy with certain lints disabled. I've also gone ahead and fixed some of the lint errors, although there are many more still to go.

cc #848 

Co-authored-by: Alan Du <[email protected]>
@matklad
Copy link
Member

matklad commented Jul 13, 2020

we have cargo xtask lint now

@matklad matklad closed this as completed Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants