From d9aa9bede68eeb45561ef2fd911e70474246791a Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Mon, 22 Nov 2021 11:18:05 +0000 Subject: [PATCH 1/2] Fix issue 1741 --- Rules/UseConsistentWhitespace.cs | 2 ++ Tests/Rules/UseConsistentWhitespace.tests.ps1 | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Rules/UseConsistentWhitespace.cs b/Rules/UseConsistentWhitespace.cs index 6112c43f9..5b1c119d1 100644 --- a/Rules/UseConsistentWhitespace.cs +++ b/Rules/UseConsistentWhitespace.cs @@ -233,6 +233,7 @@ private IEnumerable FindOpenBraceViolations(TokenOperations to if (lcurly.Previous == null || !IsPreviousTokenOnSameLine(lcurly) || lcurly.Previous.Value.Kind == TokenKind.LCurly + || lcurly.Previous.Value.Kind == TokenKind.Dot || ((lcurly.Previous.Value.TokenFlags & TokenFlags.MemberName) == TokenFlags.MemberName)) { continue; @@ -242,6 +243,7 @@ private IEnumerable FindOpenBraceViolations(TokenOperations to { continue; } + yield return new DiagnosticRecord( GetError(ErrorKind.BeforeOpeningBrace), diff --git a/Tests/Rules/UseConsistentWhitespace.tests.ps1 b/Tests/Rules/UseConsistentWhitespace.tests.ps1 index 27e17e74e..9719dbfcb 100644 --- a/Tests/Rules/UseConsistentWhitespace.tests.ps1 +++ b/Tests/Rules/UseConsistentWhitespace.tests.ps1 @@ -72,6 +72,11 @@ if ($true) Invoke-ScriptAnalyzer -ScriptDefinition '$ast.Find({ $oneAst -is [TypeExpressionAst] })' -Settings $settings | Should -BeNullOrEmpty } + + It 'Should not find a violation if an open paren is preceded by a Dot token' { + Invoke-ScriptAnalyzer -ScriptDefinition '$foo.{bar}' -Settings $settings | + Should -BeNullOrEmpty + } } Context "When a parenthesis follows a keyword" { From a0423771f965f553d009618fd9b7a59346be8068 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Mon, 22 Nov 2021 11:22:19 +0000 Subject: [PATCH 2/2] cleanup diff --- Rules/UseConsistentWhitespace.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Rules/UseConsistentWhitespace.cs b/Rules/UseConsistentWhitespace.cs index 5b1c119d1..257fc1240 100644 --- a/Rules/UseConsistentWhitespace.cs +++ b/Rules/UseConsistentWhitespace.cs @@ -243,7 +243,6 @@ private IEnumerable FindOpenBraceViolations(TokenOperations to { continue; } - yield return new DiagnosticRecord( GetError(ErrorKind.BeforeOpeningBrace),