Skip to content

Blink parity: preserve import indent in braced namespace; gate to 0.8% - #134

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-blink-parity-errorhandler
Oct 4, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv-blink-parity-errorhandler

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes the last mautic parity diff and ratchets the gate under 0.8%. Measured drop: 37 to 36 differing files of 4527 (0.795%).

The fix

SingleLineAfterImports rewrote the whitespace after the last import to a bare "\n\n", dropping the following line's indentation. Inside a braced namespace (namespace X { use ...; final class ... }) that de-indented the class to column 0. It now keeps the import line's own indentation after the blank line, and leaves a whitespace that already holds exactly one blank line untouched, matching php-cs-fixer. Top-level (non-braced) imports have an empty indent, so their behavior is unchanged.

This was initially suspected to be StatementIndentation, but a config bisect and the fixer priorities (StatementIndentation -3 runs before SingleLineAfterImports -11) pinned it to the import fixer - StatementIndentation could not repair what the import fixer mangled afterward.

Gate

MAX_DIFF_PERCENT lowered 1.0 to 0.8; actual is 0.795% (36 of 4527).

Unit tests cover the braced-namespace indent and the existing-blank-line no-op. Full blink suite, go vet and golangci-lint are green; the strict rector-src 1:1 gate stays 0-diff.

SingleLineAfterImports rewrote the whitespace after the last import to a bare
"\n\n", dropping the indentation of the following line, so a class inside a
braced namespace de-indented to column 0. Keep the import line's own indent
after the blank line and leave a whitespace that already holds one blank line
untouched, matching php-cs-fixer.
Unit-test SingleLineAfterImports preserving the following line's indent
inside a braced namespace, and lower MAX_DIFF_PERCENT to 0.8 (actual 0.795%).
@TomasVotruba
TomasVotruba merged commit d7b8b4c into main Oct 4, 2026
18 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-parity-errorhandler branch October 4, 2026 21:01
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