slb: make trailing comment fixing opt-in and skip ignored paths - #266
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.