Skip to content

Commit 4ad022d

Browse files
Update documentation and improve rule skipping logic in PSScriptAnalyzer tests
1 parent c01d855 commit 4ad022d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ For detailed documentation on the format of the settings file, see the
9898
## References and Links
9999
100100
- [PSScriptAnalyzer Documentation](https://learn.microsoft.com/powershell/module/psscriptanalyzer/)
101-
- [GitHub Super-Linter](https://github.com/github/super-linter)
101+
- [PSScriptAnalyzer Module Overview](https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules)
102+
- [PSScriptAnalyzer Rules](https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/readme?view=ps-modules)
102103
- [PSScriptAnalyzer GitHub Repository](https://github.com/PowerShell/PSScriptAnalyzer)
103104
- [Custom Rules in PSScriptAnalyzer](https://docs.microsoft.com/powershell/scripting/developer/hosting/psscriptanalyzer-extensibility)
105+
- [GitHub Super-Linter](https://github.com/github/super-linter)

scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ BeforeDiscovery {
2222
$Severeties = $ruleObjects | Select-Object -ExpandProperty Severity -Unique
2323
foreach ($ruleObject in $ruleObjects) {
2424
$skip = if ($ruleObject.RuleName -in $settings.ExcludeRules) {
25+
Write-Verbose "Skipping rule [$($ruleObject.RuleName)] - Because it is in the exclude list" -Verbose
2526
$true
2627
} elseif ($settings.IncludeRules -and $ruleObject.RuleName -notin $settings.IncludeRules) {
27-
$skip = $true
28+
Write-Verbose "Skipping rule [$($ruleObject.RuleName)] - Because it is not in the include list" -Verbose
29+
$true
2830
} elseif ($settings.Severity -and $ruleObject.Severity -notin $settings.Severity) {
29-
$skip = $true
31+
Write-Verbose "Skipping rule [$($ruleObject.RuleName)] - Because it is not in the severity list" -Verbose
32+
$true
3033
} elseif ($settings.Rules -and $settings.Rules.ContainsKey($ruleObject.RuleName) -and -not $settings.Rules[$ruleObject.RuleName].Enabled) {
31-
$skip = $true
34+
Write-Verbose "Skipping rule [$($ruleObject.RuleName)] - Because it is disabled" -Verbose
35+
$true
3236
} else {
33-
$skip = $false
37+
$false
3438
}
3539

3640
$rules.Add(

tests/srcTestRepo/tests/Custom.Settings.psd1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
'PSProvideCommentHelp'
6060
'PSUseConsistentIndentation'
6161
)
62-
IncludeDefaultRules = $false
6362
Severity = @(
6463
'Error'
6564
'Warning'

0 commit comments

Comments
 (0)