Skip to content

Commit 0f4c3aa

Browse files
author
Kapil Borle
authored
Merge pull request #700 from PowerShell/kapilmb/fix-indentation-rule
Handle DollarParen token kind in indentation rule
2 parents c23d0ae + 685e17e commit 0f4c3aa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Rules/UseConsistentIndentation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
8080
case TokenKind.AtParen:
8181
case TokenKind.LParen:
8282
case TokenKind.LCurly:
83+
case TokenKind.DollarParen:
8384
AddViolation(token, indentationLevel++, diagnosticRecords, ref onNewLine);
8485
break;
8586

Tests/Rules/UseConsistentIndentation.tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,20 @@ $param3
9797
$violations.Count | Should Be 4
9898
}
9999
}
100+
101+
Context "When a sub-expression is provided" {
102+
BeforeAll {
103+
$def = @'
104+
function foo {
105+
$x = $("abc")
106+
$x
107+
}
108+
'@
109+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
110+
}
111+
112+
It "Should not find a violations" {
113+
$violations.Count | Should Be 0
114+
}
115+
}
100116
}

0 commit comments

Comments
 (0)