-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a case to lint_search_is_some
to handle searching strings
#6119
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I think this should go into |
cafb428
to
a51e0ea
Compare
Yeah, you're right, this should go into the methods module. IMO it doesn't even have to be a new lint, but a special case in the rust-clippy/clippy_lints/src/methods/mod.rs Line 3037 in 5af88e3
|
Thanks for the comment! I will move it to Edit: So, I have done that but unfortunately, the commits are not so nice now (one of them is mostly just deleting files). Sorry about that, I am still pretty new to the PR workflow. |
a51e0ea
to
b72e769
Compare
lint_search_is_some
to handle searching strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I have done that but unfortunately, the commits are not so nice now (one of them is mostly just deleting files). Sorry about that, I am still pretty new to the PR workflow.
Don't worry about this for now, we can deal with that right before merging.
impl LGTM overall. Just a NIT and splitting up the tests left to do.
a46b437
to
df9e647
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Only a NIT left.
@rsulli55 You have to update the reference files. After that, we can merge this. |
@flip1995 Thanks. I have done that, however I was having trouble rebasing my local branch on the upstream branch so I squashed some of my earlier commits. Is that okay? I have been holding off pushing my local branch because I wasn't sure if that would cause problems. |
☔ The latest upstream changes (presumably #6197) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
b2c71f5
to
31cb5ce
Compare
clippy_lints/src/methods/mod.rs
Outdated
@@ -3073,7 +3073,7 @@ fn lint_search_is_some<'tcx>( | |||
then { | |||
let msg = "called `is_some()` after calling `find()` \ | |||
on a string. This is more succinctly expressed by calling \ | |||
`contains()`"; | |||
`contains()`."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flip1995 I added back in the period after contains()
to match the other cases of search_is_some
(they all end with a period). Let me know if you do not want that and I will remove it and re-run update-all-references
.
By the way, thank you for you patience with me! Sorry if my questions are all basic things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh they're also in other places? Can you remove them there too, please? Rust error/hint/suggestion messages are always without punctuation at the end and start lower-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also remove the second part of this message here completely and replace the "try this"
below with use `contains()` instead
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flip1995 Ok, I think they should be correctly updated. I also cleaned up the other lints in search_is_some
that suggested using any()
.
31cb5ce
to
2a575a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more NITs left. This should be the last.
instead of `find()` follows by `is_some()` on strings Update clippy_lints/src/find_is_some_on_strs.rs Co-authored-by: Takayuki Nakata <[email protected]> Update clippy_lints/src/methods/mod.rs Co-authored-by: Philipp Krones <[email protected]>
`search_is_some.rs` and `search_is_some_fixable.rs`
Co-authored-by: Philipp Krones <[email protected]>
Co-authored-by: Philipp Krones <[email protected]>
`update-all-references.sh`
Co-authored-by: Philipp Krones <[email protected]>
af3b1f4
to
5c1c50e
Compare
@bors r+ Thanks! |
📌 Commit 5c1c50e has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes: #6010
This adds a lint which recommends using
contains()
instead offind()
followed byis_some()
on strings as suggested in #6010.This was added as an additional case to
rust-clippy/clippy_lints/src/methods/mod.rs
Line 3037 in 5af88e3
I would really appreciate any comments/suggestions for my code!
changelog: Added case to
lint_search_is_some
to handle searching strings