@@ -3,6 +3,7 @@ $ruleConfiguration = @{
3
3
Enable = $true
4
4
NoEmptyLineBefore = $true
5
5
IgnoreOneLineBlock = $true
6
+ NewLineAfter = $true
6
7
}
7
8
8
9
$settings = @ {
@@ -19,6 +20,9 @@ Describe "PlaceCloseBrace" {
19
20
function foo {
20
21
Write-Output "close brace not on a new line"}
21
22
'@
23
+ $ruleConfiguration .' NoEmptyLineBefore' = $false
24
+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
25
+ $ruleConfiguration .' NewLineAfter' = $false
22
26
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
23
27
}
24
28
@@ -39,6 +43,9 @@ function foo {
39
43
40
44
}
41
45
'@
46
+ $ruleConfiguration .' NoEmptyLineBefore' = $true
47
+ $ruleConfiguration .' IgnoreOneLineBlock' = $false
48
+ $ruleConfiguration .' NewLineAfter' = $false
42
49
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
43
50
}
44
51
@@ -56,6 +63,9 @@ function foo {
56
63
$def = @'
57
64
$hashtable = @{a = 1; b = 2}
58
65
'@
66
+ $ruleConfiguration .' NoEmptyLineBefore' = $false
67
+ $ruleConfiguration .' IgnoreOneLineBlock' = $true
68
+ $ruleConfiguration .' NewLineAfter' = $false
59
69
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
60
70
}
61
71
@@ -71,6 +81,9 @@ $hashtable = @{
71
81
a = 1
72
82
b = 2}
73
83
'@
84
+ $ruleConfiguration .' NoEmptyLineBefore' = $false
85
+ $ruleConfiguration .' IgnoreOneLineBlock' = $true
86
+ $ruleConfiguration .' NewLineAfter' = $false
74
87
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
75
88
}
76
89
@@ -101,4 +114,24 @@ $x = if ($true) { "blah" } else { "blah blah" }
101
114
$violations.Count | Should Be 0
102
115
}
103
116
}
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
+ }
104
137
}
0 commit comments