Repository navigation
Fix blink YodaStyle skipping a comparison after a block's closing brace - #241
Merged
Merged
Conversation
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.
Problem
blink's
YodaStyleleftnull === $delayunchanged where ECS swaps it to$delay === null, when the comparison is the condition of a (multiline) ternary that starts right after a preceding block:Seen in
src/Illuminate/Events/Dispatcher.php(Laravel corpus), where ECS applies Yoda style but blink did not.Cause
isLeftBoundaryrecognised{but not}as a left boundary. A statement can begin directly after a block's closing brace (e.g. the}of a precedingif {...}), so the left literal operand's preceding}failed the boundary check and the swap was skipped. In isolation the comparison swapped fine; only the preceding}triggered the miss.Fix
Add
}to the left-boundary punctuation set. A}closes a preceding block, so a literal immediately after it starts a new statement and is a standalone comparison operand.Validation
}.Dispatcher.phpcorpus file - the$delay === nullline matches with no new diffs.gofmt -s -l .,go vet ./...,go test -race ./...,golangci-lint run.