@@ -66,9 +66,7 @@ BeforeDiscovery {
6666
6767 $moduleFiles = Get-ChildItem - Path $sourcePath - Recurse - Include @ (' *.psm1' , ' *.ps1' )
6868
69- $testCases = @ ()
70-
71- foreach ($moduleFile in $moduleFiles )
69+ $testCases = foreach ($moduleFile in $moduleFiles )
7270 {
7371 # Skipping Examples on Linux and macOS as they cannot be parsed.
7472 if (($IsLinux -or $IsMacOs ) -and $moduleFile.FullName -match ' Examples' )
@@ -90,8 +88,8 @@ BeforeDiscovery {
9088 $escapedRepositoryPath = [System.Text.RegularExpressions.RegEx ]::Escape($repositoryPathNormalized )
9189 $relativePath = $moduleFilePathNormalized -replace ($escapedRepositoryPath + ' /' )
9290
93- $testCases += @ {
94- ScriptPath = $moduleFile.FullName
91+ @ {
92+ ScriptPath = $moduleFile.FullName
9593 RelativePath = $relativePath
9694 }
9795 }
@@ -102,24 +100,21 @@ Describe 'Script Analyzer Rules' {
102100 BeforeAll {
103101 $repositoryPath = Resolve-Path - Path (Join-Path - Path $PSScriptRoot - ChildPath ' ../..' )
104102 $scriptAnalyzerSettingsPath = Join-Path - Path $repositoryPath - ChildPath ' .vscode/analyzersettings.psd1'
105- }
106-
107- It ' Should pass all PS Script Analyzer rules for file '' <RelativePath>'' ' - ForEach $testCases {
108- $pssaError = Invoke-ScriptAnalyzer - Path $ScriptPath - Settings $scriptAnalyzerSettingsPath
109103
110104 $parseErrorTypes = @ (
111105 ' TypeNotFound'
112106 ' RequiresModuleInvalid'
113107 )
108+ }
114109
110+ It ' Should pass all PS Script Analyzer rules for file '' <RelativePath>'' ' - ForEach $testCases {
115111 # Filter out reported parse errors that is unable to be resolved in source files
116- $pssaError = $pssaError |
112+ $pssaError = Invoke-ScriptAnalyzer - Path $ScriptPath - Settings $scriptAnalyzerSettingsPath |
117113 Where-Object - FilterScript {
118114 $_.RuleName -notin $parseErrorTypes
119115 }
120116
121- $report = $pssaError |
122- Format-Table - AutoSize | Out-String - Width 200
117+ $report = $pssaError | Format-Table - AutoSize | Out-String - Width 200
123118
124119 $pssaError | Should - HaveCount 0 - Because " all script analyzer rules should pass.`r`n`r`n $report `r`n "
125120 }
0 commit comments