-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added new lint "path_join_correction" #11208
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @xFrednet (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
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.
span_lint_and_sugg( | ||
cx, | ||
JOIN_ABSOLUTE_PATH, | ||
span.with_hi(expr.span.hi()), |
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.
Here you can just use join_arg.span
:)
clippy_lints/src/methods/mod.rs
Outdated
/// let path = std::path::Path::new("/bin"); | ||
/// let res = path.join("/sh"); | ||
/// assert_eq!(res, std::path::PathBuf::from("/sh")); |
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.
In these examples, it would be nicer to use # use std::path::Path
and then remove the leading std::path
.
/// let path = std::path::Path::new("/bin"); | |
/// let res = path.join("/sh"); | |
/// assert_eq!(res, std::path::PathBuf::from("/sh")); | |
/// # use std::path::{Path, PathBuf} | |
/// let path = Path::new("/bin"); | |
/// let joined_path = path.join("/sh"); | |
/// assert_eq!(joined_path, PathBuf::from("/sh")); |
Same in the example below
tests/ui/join_absolute_path.rs
Outdated
@@ -0,0 +1,26 @@ | |||
//@run-rustfix |
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.
rustfix only works with valid suggestions, for now, the best action is to rust remove it :)
//@run-rustfix |
"Pretty good first PR!" Proceeds to completely and utterly destroy your PR |
I finally got around to making this PR and it seems like it's solved ( Is it solved or do I save your fork just in case. Also, @xFrednet I think I'll let you have this one, as I have a lot of reviews currently. Hope it's not a problem :) |
I'm happy to do the full review :D |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits: |
I don't know what this is about. It may have to do with me accidentally committing to master instead of the new branch by complete accident. I gotta go to my day job now, though. |
Clippy has a policy that branches should be updated using rebases instead of merges. I think in this case, it would be best to squash all commits into one. That would remove the merge commits, without any hassle. Also, a small note, your most recent commits use a different name and don't link to your GH. This is fine for Clippy, but I wanted to mention it in case this was unintenional :) |
Thanks for your guidance! Hopefully this next commit is agreeable! Sorry for taking so long; I've been going through a lot of personal changes, and they're mostly related to getting out of intense physical labor for at least a little while. lol |
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.
This is a good step, the lint now detects the test cases correctly. I had some other suggests in the previous review, which were marked as Outdated since the file was renamed with the lint rename. Could you take a look at the resolved comments? They're related to the diagnostic and documentation style. Once they're addressed, we should be able to move forward :)
Sorry for taking so long; I've been going through a lot of personal changes, and they're mostly related to getting out of intense physical labor for at least a little while. lol
No problem at all. I hope this is a good change for you! :)
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.
Just a couple nits, the actual code looks pretty good
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.
This version looks good to me! Thank you for resolving all our comments. Also, thank you for your review @Centri3. ❤️
@ofeeg The commit history needs to be cleaned up a bit, before we can merge this. There should be no merge commits and the messages should all be descriptive. I would suggest squashing all commits of this PR into a single commit. This will remove the merge commits easily. Removing them with a rebase is possible, but can be a bit tricky.
And then we can merge it :)
47171d3
to
0c71347
Compare
I'm still learning how to rebase effectively. I think I did it correctly but even with no changes from the passing commit that I backed up it seems to be failing the test here on github. I'm pretty confused as to how to handle this due to all the squashing I had to do. |
b871e39
to
b868cbb
Compare
I've tried to look how this can be easily fixed, but I couln't find a good solution. Rebases can be really evil, especially when you only get started using them 🙈. In this case, I would suggest the following:
This is far from ideal, but the best way I can find right now. I have a backup of an older version of this PR under https://github.com/xFrednet/rust-clippy/tree/backup/pr/path_join_correct that branch might be a good start, if you want to see which files you touched. Sorry that the rebase has messed up the history so much. The next time, I'll try to write more detailed instruction 🙈 |
e103e8f
to
f43bc18
Compare
I think I fixed everything, but I did a force push which seems to be an awful idea. I ran cargo test on my own machine and it worked so should I just create a new PR again, or are you able to reopen the PR upon checking the recent commit? @xFrednet |
New lint `clippy::join_absolute_paths` Hey `@ofeeg,` this PR is a copy of all the changes you did in 47171d3 from PR #11208. I wasn't sure how to fix the git history. Hope you're okay with me figuring this out in this separate PR --- changelog: New lint [`join_absolute_paths`] [#11453](#11453) Closes: #10655 r? `@Centri3` Since you also gave feedback on the other PR. I hope that I copied everything correctly, but a third pair of eyes would be appreciated :D
r? xFrednet
changelog: Remade #10663 to point to a fresh branch as per request of @blyxyas
Finally got a break from my job to get around to this. Thank you guys for waiting.