|
1 | 1 | # .psscriptanalyzer.psd1 |
2 | | -# VALID for PSScriptAnalyzer 1.24.0 |
3 | | -# Notes: |
4 | | -# - No RuleSeverity (NOT supported by PSA 1.24.0 settings hashtable) |
5 | | -# - Repo-wide rules live here; “severity buckets” are enforced by your YAML (two-pass PSA run) |
6 | | -# - GUI-only suppressions and folder scoping are enforced by your YAML (post-filter), not here |
7 | | - |
8 | 2 | @{ |
9 | | - # ========================================================================= |
10 | | - # What rules are active across the repo (all folders + subfolders) |
11 | | - # ========================================================================= |
12 | | - IncludeRules = @( |
13 | | - # --- Formatting (safe autofix) --- |
14 | | - 'PSUseConsistentIndentation' |
15 | | - 'PSUseConsistentWhitespace' |
| 3 | + # IMPORTANT (PSScriptAnalyzer 1.24.0): |
| 4 | + # Valid top-level keys are: |
| 5 | + # CustomRulePath, ExcludeRules, IncludeRules, IncludeDefaultRules, |
| 6 | + # RecurseCustomRulePath, Rules, Severity |
16 | 7 |
|
17 | | - # --- Style / maintainability --- |
18 | | - 'PSAvoidUsingCmdletAliases' |
19 | | - 'PSUseDeclaredVarsMoreThanAssignments' |
20 | | - 'PSAvoidGlobalVars' |
| 8 | + IncludeDefaultRules = $true |
21 | 9 |
|
22 | | - # --- Safety / security --- |
23 | | - 'PSAvoidUsingWriteHost' |
24 | | - 'PSAvoidUsingInvokeExpression' |
25 | | - 'PSAvoidUsingEmptyCatchBlock' |
| 10 | + # Default severities to return (workflow gates on "Error" only) |
| 11 | + Severity = @('Error','Warning','Information') |
26 | 12 |
|
27 | | - # --- Correctness / state-changing --- |
28 | | - 'PSUseShouldProcessForStateChangingFunctions' |
| 13 | + # Keep this list focused and stable (corporate baseline). |
| 14 | + IncludeRules = @( |
| 15 | + 'PSAvoidUsingCmdletAliases', |
| 16 | + 'PSAvoidUsingWriteHost', |
| 17 | + 'PSAvoidUsingInvokeExpression', |
| 18 | + 'PSAvoidUsingEmptyCatchBlock', |
| 19 | + 'PSAvoidGlobalVars', |
| 20 | + 'PSUseDeclaredVarsMoreThanAssignments', |
| 21 | + 'PSUseShouldProcessForStateChangingFunctions', |
| 22 | + 'PSUseConsistentIndentation', |
| 23 | + 'PSUseConsistentWhitespace' |
29 | 24 | ) |
30 | 25 |
|
31 | | - # ========================================================================= |
32 | | - # Rule configuration (only valid keys for PSA 1.24.0) |
33 | | - # ========================================================================= |
34 | 26 | Rules = @{ |
35 | | - # ------------------------- |
36 | | - # Formatting config |
37 | | - # ------------------------- |
38 | 27 | PSUseConsistentIndentation = @{ |
39 | 28 | Enable = $true |
40 | 29 | Kind = 'space' |
|
51 | 40 | CheckSeparator = $true |
52 | 41 | } |
53 | 42 |
|
54 | | - # ------------------------- |
55 | | - # Hygiene / maintainability |
56 | | - # ------------------------- |
57 | | - PSAvoidUsingCmdletAliases = @{ |
| 43 | + PSAvoidUsingWriteHost = @{ |
58 | 44 | Enable = $true |
59 | 45 | } |
60 | 46 |
|
61 | | - PSUseDeclaredVarsMoreThanAssignments = @{ |
| 47 | + PSAvoidUsingCmdletAliases = @{ |
62 | 48 | Enable = $true |
63 | 49 | } |
64 | 50 |
|
65 | | - PSAvoidGlobalVars = @{ |
| 51 | + PSAvoidUsingInvokeExpression = @{ |
66 | 52 | Enable = $true |
67 | 53 | } |
68 | 54 |
|
69 | | - # ------------------------- |
70 | | - # Safety / security |
71 | | - # ------------------------- |
72 | | - PSAvoidUsingWriteHost = @{ |
| 55 | + PSAvoidUsingEmptyCatchBlock = @{ |
73 | 56 | Enable = $true |
74 | 57 | } |
75 | 58 |
|
76 | | - PSAvoidUsingInvokeExpression = @{ |
| 59 | + PSAvoidGlobalVars = @{ |
77 | 60 | Enable = $true |
78 | 61 | } |
79 | 62 |
|
80 | | - PSAvoidUsingEmptyCatchBlock = @{ |
| 63 | + PSUseDeclaredVarsMoreThanAssignments = @{ |
81 | 64 | Enable = $true |
82 | 65 | } |
83 | 66 |
|
84 | | - # ------------------------- |
85 | | - # Correctness |
86 | | - # ------------------------- |
87 | 67 | PSUseShouldProcessForStateChangingFunctions = @{ |
88 | 68 | Enable = $true |
89 | 69 | } |
90 | 70 | } |
91 | | - |
92 | | - # ========================================================================= |
93 | | - # Optional repo-wide Severity gate (supported key) |
94 | | - # ========================================================================= |
95 | | - # This controls which severities PSA emits when *you* do not pass -Severity. |
96 | | - # Your YAML already runs PSA in two passes (Error pass + Warning pass), |
97 | | - # so this is mostly a safe default. |
98 | | - Severity = @('Error','Warning') |
99 | 71 | } |
0 commit comments