-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPSScriptAnalyzerSettings.psd1
69 lines (56 loc) · 4.37 KB
/
PSScriptAnalyzerSettings.psd1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# PSScriptAnalyzer could be installed locally, in which case it will be at
# %UserProfile%\Documents\WindowsPowerShell\Modules\PSScriptAnalyzer\1.19.1
# But most normally today it will be used in VS Code where it is a component of the PowerShell extension:
# %UserProfile%\.vscode\extensions\ms-vscode.powershell-2024.2.1\modules\PSScriptAnalyzer\1.22.0
# There is no PSScriptAnalyzerSettings.psd1 by default, but note that PSScriptAnalyzer.psd1 is always there,
# that is a different file, don't confuse them. You can create a PSScriptAnalyzerSettings.psd1 here to apply
# to all scripts, or you can drop a custom PSScriptAnalyzerSettings.psd1 into a project folder where it will
# apply to every script in that folder.
#
# Run PSScriptAnalyzer directly via the command palette (Ctrl+Shift+P) "PSScriptAnalyzer: Analyze Script" or by right-clicking in the editor and selecting "PSScriptAnalyzer: Analyze Script".
# View Issues: After running the analyzer, any detected issues will be displayed in the "Problems" panel at the bottom of the editor. You can click on each issue to navigate to the corresponding line in the script.
# Navigate Between Issues: To navigate between the detected issues, you can use the keyboard shortcut F8 (by default). Pressing F8 will cycle through the issues one by one, highlighting each one in the editor and moving to the corresponding line.
# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/AvoidUsingCmdletAliases.md
# https://github.com/PowerShell/PSScriptAnalyzer/issues/214
@{
# Each rule statement should be separated by ; and ExcludeRules by ,
Rules = @{
PSAvoidUsingCmdletNameExceptions = @{ AllowList = @('Help') }; # I use Help-xxx Funtions that I would like to keep
# PSAvoidUsingCmdletAliases = @{ AllowList = @("ls", "cd", "gci") } # Can allow specific rules here (comment this out if ignoring *all* aliases)
}
# Do not analyze the rules in ExcludeRules. Use it when you have commented out the IncludeRules section, which means that all
# default rules will be included, *except* for those in the section below. Note that if a rule is in both IncludeRules and
# ExcludeRules, the rule will be exluded.
ExcludeRules = @(
'PSAvoidUsingWriteHost', # Suppress the rule that flags Write-Host
'PSAvoidUsingCmdletAliases', # Suppress the rule that flags aliases
'PSAvoidUsingPositionalParameters',
'PSUseShouldProcessForStateChangingFunctions' # Do not flag functions starting: New, Set, Remove, Start, Stop, Restart, Reset, Update
)
# You can also use rule configuration to configure independent rules (for those rules that support this granularity):
# Rules = @{ PSAvoidUsingCmdletAliases = @{ AllowList = @("ls", "cd", "gci") } }
# IncludeRules = @()
# Custom Rules: Specify a path to a folder containing custom rule modules. This allows you to extend the set of rules provided by default with custom rules tailored to your specific requirements.
# CustomRulePath = @(
# 'C:\Path\To\CustomRules'
# )
# Rule Severity: Define severity levels for each rule. Severity levels include Error, Warning, and Informational.
# RuleSeverity = @{
# PSAvoidUsingWriteHost = 'Warning'
# PSUseShouldProcessForStateChangingFunctions = 'Informational'
# }
# Rule Configuration: Some rules allow for additional configuration options. You can define these options using the RuleConfiguration setting.
# RuleConfiguration = @{
# PSAvoidUsingPlainTextForPassword = @{
# DescriptiveName = 'Check for plain text passwords'
# Enabled = $true
# ErrorMessage = 'Do not store passwords in plain text'
# }
# }
# DefaultRulesPath: Specifies the path to the folder containing built-in rule modules. This setting is typically predefined and doesn't need manual configuration unless you're customizing the location of the rule modules.
# DefaultRulesPath = 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\Rules'
# RecurseCustomRules: Determines whether to recursively search for custom rules in subdirectories of the path specified in CustomRulePath.
# RecurseCustomRules = $true
# MinimumVersion: Specifies the minimum version of PSScriptAnalyzer required to process the configuration file.
# MinimumVersion = '1.19.0'
}