Skip to content

Run rustfmt on channelmanager #3767

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented May 5, 2025

After reviewing a few rustfmt PRs and observing that personal preferences regarding formatting vary, I tried to do this one in a minimal way.

I went through the diff looking for blow up that really stood out, but there wasn't much that looked outside acceptable bounds to me. If anything, most of what rustfmt does is a positive change the way I see it. Reducing line density helps with readability, for me.

There were two match arms for UpdateAddHTLC that maybe received a bit too much love, even though I think even those can go through as is. Added #[rustfmt::skip] nonetheless to at least avoid what I think would be the worst pain for some.

Outstanding PRs can be rebased painlessly using a variant of the script described in #3749 (comment).

Update 5/27/2025: Added skips to every method.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented May 5, 2025

👋 Thanks for assigning @valentinewallace as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@joostjager joostjager requested a review from TheBlueMatt May 5, 2025 07:53
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 6th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 7th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 8th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 9th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@joostjager
Copy link
Contributor Author

Pushed a new take on channelmanager formatting. Used an automated script to insert the skip directives before every function.

@joostjager joostjager force-pushed the fmt-chanmgr branch 2 times, most recently from f033d19 to d7b433e Compare May 27, 2025 09:46
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.90%. Comparing base (901f72d) to head (3c9a1b5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3767      +/-   ##
==========================================
- Coverage   89.90%   89.90%   -0.01%     
==========================================
  Files         160      160              
  Lines      129222   129257      +35     
  Branches   129222   129257      +35     
==========================================
+ Hits       116182   116207      +25     
- Misses      10348    10357       +9     
- Partials     2692     2693       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot
Copy link

🔔 10th Reminder

Hey @TheBlueMatt @valentinewallace! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Concept ACK, I like this as an incremental approach, and any new methods that get added will be rustfmt'd from the start. Browsing through channelmanager.rs, it doesn't really seem too invasive to me.

Curious your thoughts moving forward after this --

Do you plan to create a follow-up removing (many of?) the skips? Or should we have a policy where going forward if a method is touched in a PR then it should be formatted?

@joostjager joostjager force-pushed the fmt-chanmgr branch 6 times, most recently from fd5301e to ae7d478 Compare May 28, 2025 10:29
@joostjager
Copy link
Contributor Author

Rebased after merge of #3802. Smooth workflow now in channelmanager.rs. Just remove a skip attribute and save (format on save) to go to standard formatting.

@joostjager
Copy link
Contributor Author

joostjager commented May 28, 2025

Concept ACK, I like this as an incremental approach, and any new methods that get added will be rustfmt'd from the start. Browsing through channelmanager.rs, it doesn't really seem too invasive to me.

It's indeed just the structs and enums that are changing. But those weren't easy to format-fix anyway.

Curious your thoughts moving forward after this --
Do you plan to create a follow-up removing (many of?) the skips? Or should we have a policy where going forward if a method is touched in a PR then it should be formatted?

Good question. If it were up to me, I'd just format the whole repository without any skips, and use the rebase script for outstanding PRs. But as there is no unanimous support for that, I am trying to at least make it better than what it was.

I think going forward from this PR, it's up to contributors to remove skip directives as they see fit. Probably based on functions touched. If that's done in a separate initial commit, and the same is done for conflicting prs that touch the same functions, I think a rebase shouldn't be problematic.

Alternatively a manual pass through this file can be made to remove some of the skips and wrap that in a separate PR. That's probably best done by someone who knows the parts of channelmgr that are in flight.

@jkczyz
Copy link
Contributor

jkczyz commented May 28, 2025

Concept ACK. I like this approach. A follow-up PR can probably remove a lot of skips where rustfmt makes trivial changes or those where there's no obvious refactoring. Then -- when touching a function in a PR -- anyone inclined could refactor it and drop the skip on a separate commit.

@joostjager
Copy link
Contributor Author

Prepared a follow up PR for the full repo: #3809

@joostjager
Copy link
Contributor Author

As discussed in sync meet, I've updated the script to drop the skip directives for functions that only need their signature to change. Added fixup commit.

@ldk-reviews-bot
Copy link

🔔 11th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 12th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@valentinewallace
Copy link
Contributor

Fixup LGTM

@joostjager joostjager force-pushed the fmt-chanmgr branch 2 times, most recently from 384ca93 to 83f41dd Compare June 3, 2025 11:56
@joostjager
Copy link
Contributor Author

Rebased. Would be nice to move towards a conclusion on this approach.

@ldk-reviews-bot
Copy link

🔔 13th Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Seems this needs yet another rebase unfortunately.

@joostjager
Copy link
Contributor Author

Rebased

This allows devs to enable rustfmt on a per-function level.
@valentinewallace
Copy link
Contributor

I heard from @joostjager that @TheBlueMatt is okay with landing this. Seems legit! Landing!

@valentinewallace valentinewallace merged commit 7b62ea4 into lightningdevkit:main Jun 4, 2025
29 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants