Skip to content

Blink parity: join block comment onto else/elseif; gate to 0.25% - #139

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-blink-parity-elseif
Oct 5, 2026
Merged

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

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Joins a block comment onto the control-continuation keyword it precedes. Measured drop: 12 to 10 differing files of 4527 (0.22%), 2 files fixed with zero regressions.

The pattern

When a block comment directly precedes else/elseif, ECS pulls the keyword onto the comment's closing */ line:

/* rule: full
 * ...
 */ elseif (preg_match('/exceed.*quota/is', $diagnosisCode)) {

blink kept elseif on its own line.

Root cause

Pinned via applied-checkers JSON and a skip-bisect to SingleSpaceAroundConstructFixer (not ControlStructureContinuationPosition). Its constructs_preceded_by_a_single_space (as, else, elseif, use_lambda) collapses the whitespace before the construct to a single space, except when a full-line ///# comment precedes it. Block and doc comments are joined.

The fix

SingleSpaceAroundConstruct.fixPreceded skipped the collapse whenever the preceding whitespace held a newline. Now, when that newline-whitespace is directly preceded by a block or doc comment, it collapses to a single space (joining */ elseif). A ///# line comment is still left alone, and the plain }\nelse case is unchanged.

Gate

MAX_DIFF_PERCENT lowered 0.3 to 0.25; actual is 0.22% (10 of 4527).

Fixed: DsnParser, BodyParser. Unit tests cover block-comment join and line-comment preservation. Full blink suite, go vet, golangci-lint green; strict rector-src 1:1 gate stays 0-diff (14 files spot-checked).

SingleSpaceAroundConstruct collapses the whitespace before else/elseif/as/
use_lambda to a single space unless a // or # line comment precedes. blink
skipped the collapse whenever the whitespace held a newline, so a block or doc
comment directly before the construct kept it on its own line. Now a block/doc
comment joins the construct onto its closing line ("*/ elseif"), while a line
comment is still left alone.
@TomasVotruba
TomasVotruba merged commit 9506943 into main Oct 5, 2026
18 checks passed
@TomasVotruba
TomasVotruba deleted the tv-blink-parity-elseif branch October 5, 2026 11:38
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