@@ -111,9 +111,9 @@ Describe 'PSModule - SourceCode tests' {
111
111
if ($skipTest.Matches.Count -gt 0 ) {
112
112
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
113
113
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping NumberOfProcessors test'
114
- continue
114
+ } else {
115
+ $issues += " - $ ( $_.Path ) :L$ ( $_.LineNumber ) "
115
116
}
116
- $issues += " - $ ( $_.Path ) :L$ ( $_.LineNumber ) "
117
117
}
118
118
}
119
119
$issues -join [Environment ]::NewLine |
@@ -128,10 +128,10 @@ Describe 'PSModule - SourceCode tests' {
128
128
if ($skipTest.Matches.Count -gt 0 ) {
129
129
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
130
130
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping Verbose test'
131
- continue
132
- }
133
- Select-String - Path $filePath - Pattern ' \s(-Verbose(?::\$true)?)\b(?!:\$false) ' - AllMatches | ForEach-Object {
134
- $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
131
+ } else {
132
+ Select-String - Path $filePath - Pattern ' \s(-Verbose(?::\$true)?)\b(?!:\$false) ' - AllMatches | ForEach-Object {
133
+ $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
134
+ }
135
135
}
136
136
}
137
137
$issues -join [Environment ]::NewLine |
@@ -146,10 +146,10 @@ Describe 'PSModule - SourceCode tests' {
146
146
if ($skipTest.Matches.Count -gt 0 ) {
147
147
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
148
148
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping OutNull test'
149
- continue
150
- }
151
- Select-String - Path $filePath - Pattern ' Out-Null ' - AllMatches | ForEach-Object {
152
- $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
149
+ } else {
150
+ Select-String - Path $filePath - Pattern ' Out-Null ' - AllMatches | ForEach-Object {
151
+ $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
152
+ }
153
153
}
154
154
}
155
155
$issues -join [Environment ]::NewLine |
@@ -164,10 +164,10 @@ Describe 'PSModule - SourceCode tests' {
164
164
if ($skipTest.Matches.Count -gt 0 ) {
165
165
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
166
166
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping NoTernary test'
167
- continue
168
- }
169
- Select-String - Path $filePath - Pattern ' (?<!\|)\s+\?\s ' - AllMatches | ForEach-Object {
170
- $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
167
+ } else {
168
+ Select-String - Path $filePath - Pattern ' (?<!\|)\s+\?\s ' - AllMatches | ForEach-Object {
169
+ $issues += " - $relativePath `:L $ ( $_ .LineNumber ) - $ ( $_ .Line ) "
170
+ }
171
171
}
172
172
}
173
173
$issues -join [Environment ]::NewLine |
@@ -182,18 +182,18 @@ Describe 'PSModule - SourceCode tests' {
182
182
if ($skipTest.Matches.Count -gt 0 ) {
183
183
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
184
184
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping LowercaseKeywords test'
185
- continue
186
- }
187
- $errors = $null
188
- $tokens = $null
189
- [System.Management.Automation.Language.Parser ]::ParseFile($FilePath , [ref ]$tokens , [ref ]$errors )
185
+ } else {
186
+ $errors = $null
187
+ $tokens = $null
188
+ [System.Management.Automation.Language.Parser ]::ParseFile($FilePath , [ref ]$tokens , [ref ]$errors )
190
189
191
- foreach ($token in $tokens ) {
192
- $keyword = $token.Text
193
- $lineNumber = $token.Extent.StartLineNumber
194
- $columnNumber = $token.Extent.StartColumnNumber
195
- if (($token.TokenFlags -match ' Keyword' ) -and ($keyword -cne $keyword.ToLower ())) {
196
- $issues += " - $relativePath `:L$lineNumber `:C$columnNumber - $keyword "
190
+ foreach ($token in $tokens ) {
191
+ $keyword = $token.Text
192
+ $lineNumber = $token.Extent.StartLineNumber
193
+ $columnNumber = $token.Extent.StartColumnNumber
194
+ if (($token.TokenFlags -match ' Keyword' ) -and ($keyword -cne $keyword.ToLower ())) {
195
+ $issues += " - $relativePath `:L$lineNumber `:C$columnNumber - $keyword "
196
+ }
197
197
}
198
198
}
199
199
}
@@ -238,12 +238,12 @@ Describe 'PSModule - SourceCode tests' {
238
238
if ($skipTest.Matches.Count -gt 0 ) {
239
239
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
240
240
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping FunctionCount test'
241
- continue
242
- }
243
- $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
244
- $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
245
- if ( $tokens .count -ne 1 ) {
246
- $issues += " - $relativePath - $ ( $tokens .Name ) "
241
+ } else {
242
+ $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
243
+ $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
244
+ if ( $tokens .count -ne 1 ) {
245
+ $issues += " - $relativePath - $ ( $tokens .Name ) "
246
+ }
247
247
}
248
248
}
249
249
$issues -join [Environment ]::NewLine |
@@ -259,12 +259,12 @@ Describe 'PSModule - SourceCode tests' {
259
259
if ($skipTest.Matches.Count -gt 0 ) {
260
260
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
261
261
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping FunctionName test'
262
- continue
263
- }
264
- $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
265
- $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
266
- if ( $tokens .Name -ne $fileName ) {
267
- $issues += " - $relativePath - $ ( $tokens .Name ) "
262
+ } else {
263
+ $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
264
+ $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
265
+ if ( $tokens .Name -ne $fileName ) {
266
+ $issues += " - $relativePath - $ ( $tokens .Name ) "
267
+ }
268
268
}
269
269
}
270
270
$issues -join [Environment ]::NewLine |
@@ -280,17 +280,17 @@ Describe 'PSModule - SourceCode tests' {
280
280
if ($skipTest.Matches.Count -gt 0 ) {
281
281
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
282
282
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping CmdletBinding test'
283
- continue
284
- }
285
- $scriptAst = [System.Management.Automation.Language.Parser ]::ParseFile($filePath , [ref ]$null , [ref ]$null )
286
- $tokens = $scriptAst.FindAll ({ $true }, $true )
287
- foreach ($token in $tokens ) {
288
- if ($token.TypeName.Name -eq ' CmdletBinding' ) {
289
- $found = $true
283
+ } else {
284
+ $scriptAst = [System.Management.Automation.Language.Parser ]::ParseFile($filePath , [ref ]$null , [ref ]$null )
285
+ $tokens = $scriptAst.FindAll ({ $true }, $true )
286
+ foreach ($token in $tokens ) {
287
+ if ($token.TypeName.Name -eq ' CmdletBinding' ) {
288
+ $found = $true
289
+ }
290
+ }
291
+ if (-not $found ) {
292
+ $issues += " - $relativePath "
290
293
}
291
- }
292
- if (-not $found ) {
293
- $issues += " - $relativePath "
294
294
}
295
295
}
296
296
$issues -join [Environment ]::NewLine |
@@ -306,17 +306,17 @@ Describe 'PSModule - SourceCode tests' {
306
306
if ($skipTest.Matches.Count -gt 0 ) {
307
307
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
308
308
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping ParamBlock test'
309
- continue
310
- }
311
- $scriptAst = [System.Management.Automation.Language.Parser ]::ParseFile($filePath , [ref ]$null , [ref ]$null )
312
- $tokens = $scriptAst.FindAll ({ $args [0 ] -is [System.Management.Automation.Language.ParamBlockAst ] }, $true )
313
- foreach ($token in $tokens ) {
314
- if ($token.count -eq 1 ) {
315
- $found = $true
309
+ } else {
310
+ $scriptAst = [System.Management.Automation.Language.Parser ]::ParseFile($filePath , [ref ]$null , [ref ]$null )
311
+ $tokens = $scriptAst.FindAll ({ $args [0 ] -is [System.Management.Automation.Language.ParamBlockAst ] }, $true )
312
+ foreach ($token in $tokens ) {
313
+ if ($token.count -eq 1 ) {
314
+ $found = $true
315
+ }
316
+ }
317
+ if (-not $found ) {
318
+ $issues += " - $relativePath "
316
319
}
317
- }
318
- if (-not $found ) {
319
- $issues += " - $relativePath "
320
320
}
321
321
}
322
322
$issues -join [Environment ]::NewLine |
@@ -358,14 +358,14 @@ Describe 'PSModule - SourceCode tests' {
358
358
if ($skipTest.Matches.Count -gt 0 ) {
359
359
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq ' Reason' } | Select-Object - ExpandProperty Value
360
360
Write-GitHubWarning - Message " - $relativePath - $skipReason " - Title ' Skipping FunctionTest test'
361
- continue
362
- }
363
- $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
364
- $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
365
- $functionName = $tokens .Name
366
- # If the file contains a function and the function name is not in the test files, add it as an issue.
367
- if ( $functionName .count -eq 1 -and $functionsInTestFiles -notcontains $functionName ) {
368
- $issues += " - $relativePath - $functionName "
361
+ } else {
362
+ $Ast = [ System.Management.Automation.Language.Parser ]::ParseFile( $filePath , [ ref ] $null , [ ref ] $null )
363
+ $tokens = $Ast .FindAll ( { $args [ 0 ] -is [ System.Management.Automation.Language.FunctionDefinitionAst ] } , $true )
364
+ $functionName = $tokens .Name
365
+ # If the file contains a function and the function name is not in the test files, add it as an issue.
366
+ if ( $functionName .count -eq 1 - and $functionsInTestFiles -notcontains $functionName ) {
367
+ $issues += " - $relativePath - $functionName "
368
+ }
369
369
}
370
370
}
371
371
$issues -join [Environment ]::NewLine |
0 commit comments