-
-
Notifications
You must be signed in to change notification settings - Fork 849
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
Some readability refactorings #833
Conversation
Thank you very much for your contribution. This is exactly the type of change I wanted to see from a ticket like #382. I always feel like I need to apologize for the current state of that method 😄. Tests currently fail on Rust 1.42. It would be great if you could make it work for 1.42. Otherwise, I'm also fine with increasing the min. supported version.
That would be great |
d0c430a
to
10a1e5d
Compare
It always happens so fast :D
here is how that went:
I now replaced everything with 1.42 equivalents, but we should keep these backports in mind for whenever msrv is increased again. While going through everything again, I noticed that I totally reverted #819 in the original draft. Maybe a regression test should be introduced? Maybe we can have a test that spawns a subprocess and has a mocked Finally, I moved some things around a bit. |
That's an option (we do something similar in |
I thought that one could just test that the program only gets called with short flags, but I agree that it is an uncommon regression. In that case, it is just something to look out for, especially with these big diffs (I only found it because I looked at the commits done to main since I first started working on this PR). Normal PRs (that is: ones that don't just move huge chunks around) should not have this problem |
eccc70f
to
ec59193
Compare
c40af25
to
77d362c
Compare
I had read all of the |
@niklasmohrin I know it's been a while but it would be great if we could get this ready for merging. I kind of don't want to merge other things before this is done. It would be fantastic if you could do a final round of updates (see my other comment) and solve the merge conflict. Thank you! For the future I suggest we rather split things up into multiple PRs. That would make the whole review and merge process much easier. |
fe5d8d7
to
df87fdd
Compare
…xitCode>` This way, callers don't need to collect into a slice / vec.
Now, the top method is `main`, then comes `run`, then the methods used in `run` follow. Generally, a method is always declared somewhere after its first use. This way, you can read the file from top to bottom with a decreasing level of abstraction (you start with very high-level processes like setting the current dir and logic for which ls command to use only comes furher down).
df87fdd
to
aa7217f
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.
Thank you! Let's merge this 😄
Hi everyone, thank you all for your work on fd :)
I recently saw the reddit post calling for contributions, so I sat down and toyed around with the codebase a bit. I found some things that I think would improve readability. The main change here is that I had rust-analyzer extract some methods from the long
run
function, because I really couldn't grasp what was happening in the bigger picture. I also changed the ordering of functions in themain.rs
file, see the commit message for rationale.There are two more commits, I also put my rationale into the commit messages there.
Of course, this is a big diff for rather little change. If you don't like any particular change (or all of them), feel free to point that out to me :)
TODO:
run
, I have to closely read all of the code again to check that nothing got lost in the process / during my rebase (tests all pass, but I would rather be sure)(somewhat related to #382, although this does not include any of the higher level suggestions)