Skip to content

style: update formatting rules - #1184

Merged
orhun merged 4 commits into
orhun:mainfrom
joshka:jm/format-spaces
Jul 27, 2025
Merged

style: update formatting rules#1184
orhun merged 4 commits into
orhun:mainfrom
joshka:jm/format-spaces

Conversation

@joshka

@joshka joshka commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

chore: update formatting rules

Use spaces instead of tabs for indentation, wrap at 100 characters, and
remove the setting that aligns struct fields vertically as this
generally harms readability.

These changes make the code more consistent with the Rust community's
conventions and improve readability by not truncating lines too early.


Justification:

https://www.youtube.com/watch\?v\=V7PLxL8jIl8

This brings things more in line with pretty much every rust project out there. Hard tabs are used in around 0.1% of rust projects:

@joshka
joshka requested a review from orhun as a code owner June 20, 2025 23:35
@codecov-commenter

codecov-commenter commented Jun 20, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.73474% with 1097 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.59%. Comparing base (e721a88) to head (7aeb48a).
⚠️ Report is 99 commits behind head on main.

Files with missing lines Patch % Lines
git-cliff/src/lib.rs 0.00% 425 Missing ⚠️
git-cliff-core/src/changelog.rs 49.55% 165 Missing ⚠️
git-cliff-core/src/remote/mod.rs 26.87% 98 Missing ⚠️
git-cliff-core/src/repo.rs 68.33% 70 Missing ⚠️
git-cliff/src/logger.rs 0.00% 62 Missing ⚠️
git-cliff-core/src/config.rs 41.98% 47 Missing ⚠️
git-cliff-core/src/remote/bitbucket.rs 29.79% 33 Missing ⚠️
git-cliff-core/src/remote/gitlab.rs 38.00% 31 Missing ⚠️
git-cliff-core/src/remote/gitea.rs 34.15% 27 Missing ⚠️
git-cliff-core/src/remote/github.rs 35.72% 27 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1184      +/-   ##
==========================================
- Coverage   43.34%   41.59%   -1.74%     
==========================================
  Files          22       22              
  Lines        2040     1919     -121     
==========================================
- Hits          884      798      -86     
+ Misses       1156     1121      -35     
Flag Coverage Δ
unit-tests 41.59% <40.74%> (-1.74%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread rustfmt.toml
Comment on lines -4 to -5
hard_tabs = true
tab_spaces = 4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the main change. Everything else is automatic formatting.

Comment thread .git-blame-ignore-revs Outdated
@orhun

orhun commented Jun 22, 2025

Copy link
Copy Markdown
Owner

I was thinking of creating a patch release for these formatting changes after I'm done with the current reviews. Otherwise it might be a bit annoying to rebase this on other PRs.

I always forget to do this though...

@joshka

joshka commented Jun 22, 2025

Copy link
Copy Markdown
Contributor Author

I was thinking of creating a patch release for these formatting changes after I'm done with the current reviews. Otherwise it might be a bit annoying to rebase this on other PRs.

I always forget to do this though...

Fixing PRs should fairly simple:

git checkout main -- rustfmt.toml
cargo +nightly fmt
git commit -am 'formatting
git push

If you're squashing merges then this shouldn't really be too much of a problem

@joshka joshka left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To actually apply this, I'd suggest grabbing rustfmt.toml, discarding everything else and rerunning cargo +nightly fmt

git reset --hard main
git reset fdf857422158338c9ec461270b1aabd31a375049 rustfmt.toml
cargo +nightly fmt
git commit -aC fdf857422158338c9ec461270b1aabd31a375049
git push
git reset 541aa64f4e60738b0ff24895b358c3f05a4b841e .git-blame-ignore-revs
# edit the file with the correct hash

Comment thread rustfmt.toml Outdated
Comment thread rustfmt.toml
@orhun

orhun commented Jun 22, 2025

Copy link
Copy Markdown
Owner

yes pls do itt

@joshka
joshka force-pushed the jm/format-spaces branch 2 times, most recently from 87616d0 to 51427a4 Compare June 28, 2025 23:13

@joshka joshka left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the rev ignore file - do this in a followup PR

Comment thread rust-toolchain.toml Outdated
Comment thread rustfmt.toml
@joshka joshka changed the title chore: use spaces instead tabs chore: update formatting rules Jun 28, 2025
@joshka joshka changed the title chore: update formatting rules style: update formatting rules Jun 28, 2025
@joshka
joshka force-pushed the jm/format-spaces branch from b1a6305 to f30bfb9 Compare June 28, 2025 23:45
Use spaces instead of tabs for indentation, wrap at 100 characters, and
remove the setting that aligns struct fields vertically as this
generally harms readability.

These changes make the code more consistent with the Rust community's
conventions and improve readability by not truncating lines too early.
@joshka
joshka force-pushed the jm/format-spaces branch from f30bfb9 to 16fbf87 Compare July 1, 2025 00:07
@joshka

joshka commented Jul 1, 2025

Copy link
Copy Markdown
Contributor Author

Rebased

@orhun
orhun merged commit 0027300 into orhun:main Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants