Skip to content

Commit b5af8d7

Browse files
authored
Skip OpenBrace check when preceded by Dot token (#1750)
* Fix issue 1741 * cleanup diff
1 parent 2891c2a commit b5af8d7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Rules/UseConsistentWhitespace.cs

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ private IEnumerable<DiagnosticRecord> FindOpenBraceViolations(TokenOperations to
233233
if (lcurly.Previous == null
234234
|| !IsPreviousTokenOnSameLine(lcurly)
235235
|| lcurly.Previous.Value.Kind == TokenKind.LCurly
236+
|| lcurly.Previous.Value.Kind == TokenKind.Dot
236237
|| ((lcurly.Previous.Value.TokenFlags & TokenFlags.MemberName) == TokenFlags.MemberName))
237238
{
238239
continue;

Tests/Rules/UseConsistentWhitespace.tests.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ if ($true)
7272
Invoke-ScriptAnalyzer -ScriptDefinition '$ast.Find({ $oneAst -is [TypeExpressionAst] })' -Settings $settings |
7373
Should -BeNullOrEmpty
7474
}
75+
76+
It 'Should not find a violation if an open paren is preceded by a Dot token' {
77+
Invoke-ScriptAnalyzer -ScriptDefinition '$foo.{bar}' -Settings $settings |
78+
Should -BeNullOrEmpty
79+
}
7580
}
7681

7782
Context "When a parenthesis follows a keyword" {

0 commit comments

Comments
 (0)