@@ -67,9 +67,7 @@ BeforeDiscovery {
6767
6868 $moduleFiles = Get-ChildItem - Path $sourcePath - Recurse - Include @ (' *.psm1' , ' *.ps1' )
6969
70- $testCases = @ ()
71-
72- foreach ($moduleFile in $moduleFiles )
70+ $testCases = foreach ($moduleFile in $moduleFiles )
7371 {
7472 # Skipping Examples on Linux and macOS as they cannot be parsed.
7573 if (($IsLinux -or $IsMacOs ) -and $moduleFile.FullName -match ' Examples' )
@@ -91,8 +89,8 @@ BeforeDiscovery {
9189 $escapedRepositoryPath = [System.Text.RegularExpressions.RegEx ]::Escape($repositoryPathNormalized )
9290 $relativePath = $moduleFilePathNormalized -replace ($escapedRepositoryPath + ' /' )
9391
94- $testCases += @ {
95- ScriptPath = $moduleFile.FullName
92+ @ {
93+ ScriptPath = $moduleFile.FullName
9694 RelativePath = $relativePath
9795 }
9896 }
@@ -103,24 +101,21 @@ Describe 'Script Analyzer Rules' {
103101 BeforeAll {
104102 $repositoryPath = Resolve-Path - Path (Join-Path - Path $PSScriptRoot - ChildPath ' ../..' )
105103 $scriptAnalyzerSettingsPath = Join-Path - Path $repositoryPath - ChildPath ' .vscode/analyzersettings.psd1'
106- }
107-
108- It ' Should pass all PS Script Analyzer rules for file '' <RelativePath>'' ' - ForEach $testCases {
109- $pssaError = Invoke-ScriptAnalyzer - Path $ScriptPath - Settings $scriptAnalyzerSettingsPath
110104
111105 $parseErrorTypes = @ (
112106 ' TypeNotFound'
113107 ' RequiresModuleInvalid'
114108 )
109+ }
115110
111+ It ' Should pass all PS Script Analyzer rules for file '' <RelativePath>'' ' - ForEach $testCases {
116112 # Filter out reported parse errors that is unable to be resolved in source files
117- $pssaError = $pssaError |
113+ $pssaError = Invoke-ScriptAnalyzer - Path $ScriptPath - Settings $scriptAnalyzerSettingsPath |
118114 Where-Object - FilterScript {
119115 $_.RuleName -notin $parseErrorTypes
120116 }
121117
122- $report = $pssaError |
123- Format-Table - AutoSize | Out-String - Width 200
118+ $report = $pssaError | Format-Table - AutoSize | Out-String - Width 200
124119
125120 $pssaError | Should - HaveCount 0 - Because " all script analyzer rules should pass.`r`n`r`n $report `r`n "
126121 }
0 commit comments