Skip to content

slb: make trailing comment fixing opt-in and skip ignored paths - #266

Merged
Esgrove merged 1 commit into
mainfrom
slb/trailing-opt-in-and-gitignore
Sep 15, 2026
Merged

Esgrove merged 1 commit into
mainfrom
slb/trailing-opt-in-and-gitignore

Conversation

@Esgrove

@Esgrove Esgrove commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Moving a comment off a code line rewrites code, and the result often reads worse than what was there, so the trailing rule is no longer part of the default set. RuleSet::DEFAULT is every rule except that one, and -T/--trailing turns it back on so it composes with -R and the config rules list instead of replacing them. The rule gates checking as well as fixing, so a default run no longer reports trailing comments either.

When a comment already sits directly above the code line, the trailing comment is now reported but not moved. Moving it there put it in the same comment block as the comment above, and the reflow then joined the two into one sentence: a note reading "below threshold of 15" followed by "6 chars" came out as "below threshold of 15 6 chars". Keeping the moved line apart was tried first, by marking the break before the last line of a comment block above code so the reflow could not join it away. That cannot tell a moved annotation from a genuinely wrapped line, and it stopped three fixtures reflowing their prose, so the conservative report is what remains. The same check now also leaves a comment on a line that closes a block comment alone, which avoids writing the moved comment inside the block.

A run with -x also walked target/ and rewrote vendored C headers, because the command line excludes replaced the built-in list rather than adding to it, dropping target and node_modules along with it. They add to it now. The walk also moved from walkdir to the ignore crate, so paths the repository ignores are skipped, with -n/--no-ignore and the use_gitignore config key to turn that off. The built-in excludes stay as the safety net outside git repositories, where gitignore rules do not apply.

Moving a comment off a code line rewrites code, and the result often
reads worse than what was there, so the trailing rule is no longer part
of the default set. RuleSet::DEFAULT is every rule except that one, and
-T/--trailing turns it back on so it composes with -R and the config
rules list instead of replacing them. The rule gates checking as well as
fixing, so a default run no longer reports trailing comments either.

When a comment already sits directly above the code line, the trailing
comment is now reported but not moved. Moving it there put it in the
same comment block as the comment above, and the reflow then joined the
two into one sentence: a note reading "below threshold of 15" followed
by "6 chars" came out as "below threshold of 15 6 chars". Keeping the
moved line apart was tried first, by marking the break before the last
line of a comment block above code so the reflow could not join it away.
That cannot tell a moved annotation from a genuinely wrapped line, and
it stopped three fixtures reflowing their prose, so the conservative
report is what remains. The same check now also leaves a comment on a
line that closes a block comment alone, which avoids writing the moved
comment inside the block.

A run with -x also walked target/ and rewrote vendored C headers,
because the command line excludes replaced the built-in list rather than
adding to it, dropping target and node_modules along with it. They add
to it now. The walk also moved from walkdir to the ignore crate, so
paths the repository ignores are skipped, with -n/--no-ignore and the
use_gitignore config key to turn that off. The built-in excludes stay as
the safety net outside git repositories, where gitignore rules do not
apply.
@Esgrove
Esgrove merged commit 7d608d1 into main Sep 15, 2026
3 of 4 checks passed
@Esgrove
Esgrove deleted the slb/trailing-opt-in-and-gitignore branch September 15, 2026 15:25
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.

1 participant