From 4c1e248aad009f9e49db8a333f85723126e86216 Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 2 Feb 2017 09:16:15 -0800 Subject: [PATCH 1/2] Handle token of kind DollarParen --- Rules/UseConsistentIndentation.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Rules/UseConsistentIndentation.cs b/Rules/UseConsistentIndentation.cs index efb0c2b6a..099002274 100644 --- a/Rules/UseConsistentIndentation.cs +++ b/Rules/UseConsistentIndentation.cs @@ -80,6 +80,7 @@ public override IEnumerable AnalyzeScript(Ast ast, string file case TokenKind.AtParen: case TokenKind.LParen: case TokenKind.LCurly: + case TokenKind.DollarParen: AddViolation(token, indentationLevel++, diagnosticRecords, ref onNewLine); break; From 685e17ed9fbc9b29b1b3ed0ec0ebca1920dacebe Mon Sep 17 00:00:00 2001 From: Kapil Borle Date: Thu, 2 Feb 2017 09:25:58 -0800 Subject: [PATCH 2/2] Add test to handle DollarParen token kind --- Tests/Rules/UseConsistentIndentation.tests.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/Rules/UseConsistentIndentation.tests.ps1 b/Tests/Rules/UseConsistentIndentation.tests.ps1 index 1d6eaae02..51b411a70 100644 --- a/Tests/Rules/UseConsistentIndentation.tests.ps1 +++ b/Tests/Rules/UseConsistentIndentation.tests.ps1 @@ -97,4 +97,20 @@ $param3 $violations.Count | Should Be 4 } } + + Context "When a sub-expression is provided" { + BeforeAll { + $def = @' +function foo { + $x = $("abc") + $x +} +'@ + $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings + } + + It "Should not find a violations" { + $violations.Count | Should Be 0 + } + } }