rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Rustfmt Maximalism

Open joostjager opened this issue 8 months ago • 12 comments

Just enable it globally. We can take care of format refactors later or as we update the code, and this way we immediately eliminate the ongoing formatting micro-penalties.

To auto-format in-flight PRs without manual conflict resolution:

Let's say commit X is the commit where all of main is rustfmt'ed. Nothing other dan cargo fmt should have been done in this commit.

  • First rebase the branch normally onto the predecessor of X (still without formatting) to resolve any outstanding conflicts.
  • Create and checkout a new branch for the rewrite off of X.
  • Run the following script, replace BRANCH with the branch to replay:
#!/bin/bash

echo Start

BRANCH="2025-04-rustfmt-tests-1"
for commit in $(git rev-list --reverse HEAD..$BRANCH); do
    echo "Commit: $commit"
    git restore --source=$commit .

    cargo fmt

    git add .
    git commit -c $commit --no-edit --allow-empty
done
  • Now every commit in the new branch is rustfmted and exists on top of formatted main.

joostjager avatar Apr 25 '25 05:04 joostjager

👋 I see @wpaulino was un-assigned. If you'd like another reviewer assignemnt, please click here.

ldk-reviews-bot avatar Apr 25 '25 05:04 ldk-reviews-bot

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar Apr 28 '25 00:04 ldk-reviews-bot

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar Apr 28 '25 00:04 ldk-reviews-bot

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar Apr 28 '25 00:04 ldk-reviews-bot

🔔 2nd Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar Apr 30 '25 00:04 ldk-reviews-bot

🔔 2nd Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar Apr 30 '25 00:04 ldk-reviews-bot

To be sure we wouldn't get any problems with in-flight prs, I tried the filter-branch command from the PR description on #3751: https://github.com/joostjager/rust-lightning/compare/main-fmt...joostjager:rust-lightning:rustfmt-tests-rewritten

joostjager avatar Apr 30 '25 13:04 joostjager

Another option that could be used is #[rustfmt::skip] on the method level, for code that turns out unreadable beyond personal preference.

joostjager avatar May 01 '25 20:05 joostjager

After rebasing my own rustfmt stuff I realized that the main rebase logic won't actually work in some cases around indentation changes. Because git sometimes mis-identifies hunks as non-conflict it'll end up duplicating some lines.

TheBlueMatt avatar May 01 '25 22:05 TheBlueMatt

After rebasing my own rustfmt stuff I realized that the main rebase logic won't actually work in some cases around indentation changes. Because git sometimes mis-identifies hunks as non-conflict it'll end up duplicating some lines.

I didn't run into this yet, but had identified the potential problem too. Updated the PR description with a new approach that strictly avoids any type of merge logic / automatic conflict resolution.

joostjager avatar May 02 '25 07:05 joostjager

🔔 3rd Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 03 '25 00:05 ldk-reviews-bot

🔔 3rd Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 03 '25 00:05 ldk-reviews-bot

🔔 4th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 05 '25 00:05 ldk-reviews-bot

🔔 4th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 05 '25 00:05 ldk-reviews-bot

🔔 5th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 07 '25 00:05 ldk-reviews-bot

🔔 5th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 07 '25 00:05 ldk-reviews-bot

🔔 6th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 10 '25 00:05 ldk-reviews-bot

🔔 6th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 10 '25 00:05 ldk-reviews-bot

🔔 7th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 12 '25 00:05 ldk-reviews-bot

🔔 7th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 12 '25 00:05 ldk-reviews-bot

🔔 8th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 14 '25 00:05 ldk-reviews-bot

🔔 8th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 14 '25 00:05 ldk-reviews-bot

🔔 9th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 17 '25 00:05 ldk-reviews-bot

🔔 9th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 17 '25 00:05 ldk-reviews-bot

🔔 10th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 19 '25 00:05 ldk-reviews-bot

🔔 10th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 19 '25 00:05 ldk-reviews-bot

🔔 11th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 21 '25 00:05 ldk-reviews-bot

🔔 11th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 21 '25 00:05 ldk-reviews-bot

🔔 12th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 24 '25 00:05 ldk-reviews-bot

🔔 12th Reminder

Hey @TheBlueMatt @jkczyz @wpaulino! 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 avatar May 24 '25 00:05 ldk-reviews-bot