Add new lint `negative_feature_names` and `redundant_feature_names` by Labelray...
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.
New issue
Add new lint negative_feature_names
and redundant_feature_names
#7539
Merged
Conversation
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
]
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.
There are two separate issues being linted here:
- Features beginning with
no-
ornot-
- features should be additive, the name suggests otherwise - Features beginning with
use-
orwith-
- 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
Good advices! I am going to close this PR and implement two separate lints:
- [
feature_name_redundancy
] detecting prefixwith-
,use-
and postfixsupport
- [
negative_feature_name
] detecting prefixnot-
,no-
You could, if you want, reopen and edit this PR. The two lints can have a shared implementation, just with two declare_clippy_lint!
.
Lints [negative_feature_name
] and [redundant_feature_name
] done
There are still unresolved comments from previous reviews.
There is still an empty stderr file to be deleted.
Getting close. Thanks for your patience.
Good to go! Please squash commits.
Can you squash the first commit as well since we are not keeping the initial lint name?
Also please update the PR title and changelog in first post.
changed the title
Add new lint confusing_features_naming
Add new lint negative_feature_names
and redundant_feature_names
Thanks! @bors r+
Commit 0a021d5 has been approved by camsteffen
None yet
No milestone
Successfully merging this pull request may close these issues.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK