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

Added new lint "path_join_correction" #11208

Closed
wants to merge 1 commit into from

Conversation

ofeeg
Copy link
Contributor

@ofeeg ofeeg commented Jul 21, 2023

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.

@rustbot
Copy link
Collaborator

rustbot commented Jul 21, 2023

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 21, 2023
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ofeeg, welcome back! This version is already a good start. I left several comments, once they are addressed, we should have a working lint. Please don't hesitate to reach out if you have any questions!

@rustbot author

CHANGELOG.md Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_path.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_path.rs Outdated Show resolved Hide resolved
span_lint_and_sugg(
cx,
JOIN_ABSOLUTE_PATH,
span.with_hi(expr.span.hi()),
Copy link
Member

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/join_absolute_path.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
Comment on lines 3277 to 3279
/// let path = std::path::Path::new("/bin");
/// let res = path.join("/sh");
/// assert_eq!(res, std::path::PathBuf::from("/sh"));
Copy link
Member

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.

Suggested change
/// 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

@@ -0,0 +1,26 @@
//@run-rustfix
Copy link
Member

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 :)

Suggested change
//@run-rustfix

clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_path.rs Outdated Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jul 24, 2023
@blyxyas
Copy link
Member

blyxyas commented Jul 24, 2023

"Pretty good first PR!"

Proceeds to completely and utterly destroy your PR

@blyxyas
Copy link
Member

blyxyas commented Jul 25, 2023

I'll make a PR against your fork in a few hours

I finally got around to making this PR and it seems like it's solved (cargo uitest has no errors). There's still the cargo dev fmt issue but that's minor.

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 :)

@xFrednet
Copy link
Member

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

@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2023

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:

$ # rebase
$ git rebase -i master
$ # delete any merge commits in the editor that appears
$ git push --force-with-lease

The following commits are merge commits:

@ofeeg
Copy link
Contributor Author

ofeeg commented Jul 27, 2023

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:

$ # rebase
$ git rebase -i master
$ # delete any merge commits in the editor that appears
$ git push --force-with-lease

The following commits are merge commits:

* [1f26d8c](https://github.com/rust-lang/rust-clippy/commit/1f26d8cbd387f0bd459dfdaff44154909b8850df)

* [1d77675](https://github.com/rust-lang/rust-clippy/commit/1d7767588cbaa967c8f40128866470cb7ac78256)

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.

@xFrednet
Copy link
Member

xFrednet commented Aug 1, 2023

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 :)

@ofeeg
Copy link
Contributor Author

ofeeg commented Aug 3, 2023

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

Copy link
Member

@xFrednet xFrednet left a 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! :)

clippy_lints/src/methods/join_absolute_paths.rs~ Outdated Show resolved Hide resolved
Copy link
Member

@Centri3 Centri3 left a 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

clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_paths.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_paths.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/join_absolute_paths.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
tests/ui/join_absolute_paths.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@xFrednet xFrednet left a 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 :)

@ofeeg
Copy link
Contributor Author

ofeeg commented Aug 14, 2023

This version looks good to me! Thank you for resolving all our comments. Also, thank you for your review @Centri3. heart

@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 :)

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.

@xFrednet
Copy link
Member

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:

  1. Create a backup branch
  2. Reset this branch to have no changes at all
  3. Copy the files you touched onto this branch
  4. Add a commit for them

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 🙈

@ofeeg
Copy link
Contributor Author

ofeeg commented Aug 27, 2023

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

@xFrednet
Copy link
Member

xFrednet commented Sep 2, 2023

Hey @ofeeg, something is still of, but I'm not quite sure what. I created #11453 which should include all theses changes :)

bors added a commit that referenced this pull request Nov 20, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants