@@ -3,6 +3,7 @@ $ruleConfiguration = @{
33 Enable = $true
44 NoEmptyLineBefore = $true
55 IgnoreOneLineBlock = $true
6+ NewLineAfter = $true
67}
78
89$settings = @ {
@@ -19,6 +20,9 @@ Describe "PlaceCloseBrace" {
1920function foo {
2021 Write-Output "close brace not on a new line"}
2122'@
23+ $ruleConfiguration .' NoEmptyLineBefore' = $false
24+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
25+ $ruleConfiguration .' NewLineAfter' = $false
2226 $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
2327 }
2428
@@ -39,6 +43,9 @@ function foo {
3943
4044}
4145'@
46+ $ruleConfiguration .' NoEmptyLineBefore' = $true
47+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
48+ $ruleConfiguration .' NewLineAfter' = $false
4249 $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
4350 }
4451
@@ -56,6 +63,9 @@ function foo {
5663 $def = @'
5764$hashtable = @{a = 1; b = 2}
5865'@
66+ $ruleConfiguration .' NoEmptyLineBefore' = $false
67+ $ruleConfiguration .' IgnoreOneLineBlock' = $true
68+ $ruleConfiguration .' NewLineAfter' = $false
5969 $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
6070 }
6171
@@ -71,6 +81,9 @@ $hashtable = @{
7181 a = 1
7282 b = 2}
7383'@
84+ $ruleConfiguration .' NoEmptyLineBefore' = $false
85+ $ruleConfiguration .' IgnoreOneLineBlock' = $true
86+ $ruleConfiguration .' NewLineAfter' = $false
7487 $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
7588 }
7689
@@ -101,4 +114,24 @@ $x = if ($true) { "blah" } else { "blah blah" }
101114 $violations.Count | Should Be 0
102115 }
103116 }
117+
118+ Context " When a close brace should be follow a new line" {
119+ BeforeAll {
120+ $def = @'
121+ if (Test-Path "blah") {
122+ "blah"
123+ } else {
124+ "blah blah"
125+ }
126+ '@
127+ $ruleConfiguration .' NoEmptyLineBefore' = $false
128+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
129+ $ruleConfiguration .' NewLineAfter' = $true
130+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
131+ }
132+
133+ It " Should find two violations" {
134+ $violations.Count | Should Be 2
135+ }
136+ }
104137}
0 commit comments