Skip to content

Commit 573c7a6

Browse files
Refactor PSScriptAnalyzer tests to simplify skip logic and update custom settings structure
1 parent 32a63ac commit 573c7a6

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ BeforeDiscovery {
2727
$skip = $true
2828
} elseif ($settings.Severity -and $ruleObject.Severity -notin $settings.Severity) {
2929
$skip = $true
30-
} elseif ($settings.SourceType -and $ruleObject.SourceType -notin $settings.SourceType) {
31-
$skip = $true
32-
} elseif ($settings.SourceName -and $ruleObject.SourceName -notin $settings.SourceName) {
33-
$skip = $true
3430
} elseif ($settings.Rules -and $settings.Rules.ContainsKey($ruleObject.RuleName) -and -not $settings.Rules[$ruleObject.RuleName].Enabled) {
3531
$skip = $true
3632
} else {
3733
$skip = $false
3834
}
35+
3936
$rules.Add(
4037
[ordered]@{
4138
RuleName = $ruleObject.RuleName

tests/srcTestRepo/tests/Custom.Settings.psd1

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
Rules = @{
2+
Rules = @{
33
PSAlignAssignmentStatement = @{
44
Enable = $true
55
CheckHashtable = $true
@@ -49,24 +49,19 @@
4949
IgnoreAssignmentOperatorInsideHashTable = $true
5050
}
5151
}
52-
ExcludeRules = @(
52+
ExcludeRules = @(
5353
'PSUseConsistentWhitespace'
5454
)
55-
IncludedRules = @(
55+
IncludeRules = @(
5656
'PSAvoidSemicolonsAsLineTerminators'
5757
'PSPlaceCloseBrace'
5858
'PSPlaceOpenBrace'
5959
'PSProvideCommentHelp'
6060
'PSUseConsistentIndentation'
6161
)
62-
Severity = @(
62+
IncludeDefaultRules = $true
63+
Severity = @(
6364
'Error'
6465
'Warning'
6566
)
66-
SourceType = @(
67-
'Builtin'
68-
)
69-
SourceName = @(
70-
'PS'
71-
)
7267
}

0 commit comments

Comments
 (0)