-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSScriptAnalyzerSettings.psd1
176 lines (157 loc) · 7.89 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Use the PowerShell extension setting `powershell.scriptAnalysis.settingsPath` to get the current workspace
# to use this PSScriptAnalyzerSettings.psd1 file to configure code analysis in Visual Studio Code.
# This setting is configured in the workspace's `.vscode\settings.json`.
#
# For more information on PSScriptAnalyzer settings see:
# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/README.md#settings-support-in-scriptanalyzer
#
# You can see the predefined PSScriptAnalyzer settings here:
# https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine/Settings
@{
# Only diagnostic records of the specified severity will be generated.
# Uncomment the following line if you only want Errors and Warnings but
# not Information diagnostic records.
#Severity = @('Error','Warning')
# Analyze **only** the following rules. Use IncludeRules when you want
# to invoke only a small subset of the default rules.
<# IncludeRules = @(
'PSAvoidDefaultValueSwitchParameter'
'PSMisleadingBacktick'
'PSMissingModuleManifestField'
'PSReservedCmdletChar'
'PSReservedParams'
'PSShouldProcess'
'PSUseApprovedVerbs'
'PSAvoidUsingCmdletAliases'
'PSUseDeclaredVarsMoreThanAssignments'
) #>
# Do not analyze the following rules. Use ExcludeRules when you have
# commented out the IncludeRules settings above and want to include all
# the default rules except for those you exclude below.
# Note: if a rule is in both IncludeRules and ExcludeRules, the rule
# will be excluded.
<# ExcludeRules = @(
'PSAvoidUsingWriteHost'
) #>
IncludeDefaultRules = $true
# You can use rule configuration to configure rules that support it:
Rules = @{
PSAlignAssignmentStatement = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/AlignAssignmentStatement
Enable = $true
CheckHashtable = $true
}
PSAvoidLongLines = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/AvoidLongLines
Enable = $true
MaximumLineLength = 115
}
<# PSAvoidOverwritingBuiltInCmdlets = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/avoidoverwritingbuiltincmdlets
'PowerShellVersion' = @(
#'desktop-2.0-windows'
#'desktop-3.0-windows'
#'desktop-4.0-windows'
'desktop-5.1.14393.206-windows'
'core-6.1.0-windows'
#'core-6.1.0-linux'
#'core-6.1.0-macos'
)
} #>
PSAvoidSemicolonsAsLineTerminators = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/avoidsemicolonsaslineterminators
Enable = $true
}
<# PSAvoidUsingCmdletAliases = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/AvoidUsingCmdletAliases
# Do not flag 'cd' alias.
AllowList = @('cd')
} #>
PSAvoidUsingDoubleQuotesForConstantString = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/AvoidUsingDoubleQuotesForConstantString
Enable = $true
}
PSPlaceCloseBrace = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/PlaceCloseBrace
Enable = $true
NoEmptyLineBefore = $true
NewLineAfter = $false
}
PSPlaceOpenBrace = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/PlaceOpenBrace
Enable = $true
}
PSProvideCommentHelp = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/ProvideCommentHelp
Placement = 'begin'
}
PSUseCompatibleCmdlets = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseCompatibleCmdlets
Compatibility = @(
'desktop-2.0-windows'
)
}
PSUseCompatibleCommands = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseCompatibleCommands
Enable = $true
TargetProfiles = @(
'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework' # Server 2012
'win-8_x64_6.3.9600.0_4.0_x64_4.0.30319.42000_framework' # Server 2012 R2
'win-8_x64_10.0.14393.0_5.1.14393.2791_x64_4.0.30319.42000_framework' # Server 2016
'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Server 2019
'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Win10
#'win-8_x64_10.0.14393.0_7.0.0_x64_3.1.2_core' # Server 2016 PS 7
#'win-8_x64_10.0.17763.0_7.0.0_x64_3.1.2_core' # Server 2019 PS 7
'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' # Win10 PS 7
#'ubuntu_x64_18.04_7.0.0_x64_3.1.2_core'
)
# You can specify commands to not check like this, which also will ignore its parameters:
<# IgnoreCommands = @(
'Install-Module'
) #>
}
PSUseCompatibleSyntax = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseCompatibleSyntax
Enable = $true
TargetVersions = @(
'6.0'
'5.1'
'3.0'
)
}
PSUseCompatibleTypes = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseCompatibleTypes
Enable = $true
TargetProfiles = @(
'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework' # Server 2012
'win-8_x64_6.3.9600.0_4.0_x64_4.0.30319.42000_framework' # Server 2012 R2
'win-8_x64_10.0.14393.0_5.1.14393.2791_x64_4.0.30319.42000_framework' # Server 2016
'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Server 2019
'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Win10
'win-8_x64_10.0.14393.0_7.0.0_x64_3.1.2_core' # Server 2016 PS 7
'win-8_x64_10.0.17763.0_7.0.0_x64_3.1.2_core' # Server 2019 PS 7
'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' # Win10 PS 7
#'ubuntu_x64_18.04_7.0.0_x64_3.1.2_core'
)
# You can specify types to not check like this, which will also ignore methods and members on it:
<# IgnoreTypes = @(
'System.IO.Compression.ZipFile'
) #>
}
<# PSUseConsistentIndentation = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseConsistentIndentation
Enable = $true
} #>
PSUseConsistentWhitespace = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/UseConsistentWhitespace
Enable = $true
CheckParameter = $true
CheckPipeForRedundantWhitespace = $true
IgnoreAssignmentOperatorInsideHashTable = $true
}
PSUseCorrectCasing = @{
# https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/usecorrectcasing
Enable = $true
}
}
}