3

Add new lint `negative_feature_names` and `redundant_feature_names` by Labelray...

 3 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/7539
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

New issue

Add new lint negative_feature_names and redundant_feature_names #7539

Merged

bors merged 1 commit into

rust-lang:master

from

Labelray:master

4 days ago

Conversation

Copy link

Contributor

Labelray commented 21 days ago

edited

Add new lint [negative_feature_names] to detect feature names with prefixes no- or not- and new lint [redundant_feature_names] to detect feature names with prefixes use-, with- or suffix -support
changelog: Add new lint [negative_feature_names] and [redundant_feature_names]

Copy link

Collaborator

rust-highfive commented 21 days ago

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @camsteffen (or someone else) soon.

Please see the contribution instructions for more information.

Copy link

Collaborator

camsteffen commented 21 days ago

There are two separate issues being linted here:

  • Features beginning with no- or not- - features should be additive, the name suggests otherwise
  • Features beginning with use- or with- - needless prefix

I think this should be two separate lints - negative_feature_name and feature_name_verbosity (feel free to offer other ideas). I don't think "confusing" is the right word in either case. The lint output should clearly explain what is wrong with the name.

Otherwise, this is nice, thanks!

Fixes #1746

Could -support postfix be detected too? For example

[features]
embedded-graphics-support = ["embedded-graphics"]
serde-support = ["serde"]
tokio-support = ["tokio"]

Here's plenty of examples of this in the wild: https://grep.app/search?q=-support%20%3D%20%5B&filter[path.pattern][0]=Cargo.toml&filter[lang][0]=TOML

Copy link

Contributor

Author

Labelray commented 20 days ago

Good advices! I am going to close this PR and implement two separate lints:

  • [feature_name_redundancy] detecting prefix with-, use- and postfix support
  • [negative_feature_name] detecting prefix not-, no-

Copy link

Collaborator

camsteffen commented 20 days ago

You could, if you want, reopen and edit this PR. The two lints can have a shared implementation, just with two declare_clippy_lint!.

Copy link

Contributor

Author

Labelray commented 19 days ago

Lints [negative_feature_name] and [redundant_feature_name] done

Copy link

Collaborator

camsteffen left a comment

There are still unresolved comments from previous reviews.

clippy_lints/src/feature_name.rs

Outdated

Show resolved

Copy link

Collaborator

camsteffen left a comment

There is still an empty stderr file to be deleted.

Copy link

Collaborator

camsteffen left a comment

Getting close. Thanks for your patience.

Copy link

Collaborator

camsteffen left a comment

Good to go! Please squash commits.

Copy link

Collaborator

camsteffen commented 7 days ago

Can you squash the first commit as well since we are not keeping the initial lint name?

Copy link

Collaborator

camsteffen commented 7 days ago

Also please update the PR title and changelog in first post.

Labelray

changed the title Add new lint confusing_features_naming

Add new lint negative_feature_names and redundant_feature_names

6 days ago

Copy link

Collaborator

camsteffen commented 4 days ago

Thanks! @bors r+

Copy link

Contributor

bors commented 4 days ago

pushpin Commit 0a021d5 has been approved by camsteffen

Copy link

Contributor

bors commented 4 days ago

hourglass Testing commit 0a021d5 with merge 22606e7...

bors

merged commit 22606e7 into rust-lang:master 4 days ago

8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK