-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSScriptAnalyzerSettings.psd1
More file actions
78 lines (73 loc) · 3.83 KB
/
Copy pathPSScriptAnalyzerSettings.psd1
File metadata and controls
78 lines (73 loc) · 3.83 KB
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
# Shared estate PSScriptAnalyzer settings.
#
# ONE file, at the repository root, read by BOTH the pre-commit hook and the
# VS Code PowerShell extension. Keeping it in .vscode/ - which is where this
# started life in sysadmin-toolkit - means the editor and the commit gate
# enforce different rules, and the editor's are the ones nobody sees fail.
#
# NO Severity key on purpose. The hook passes -Severity Error explicitly and a
# command-line parameter overrides the settings file, so declaring Severity here
# would be a value that silently never applies. Running the analyser by hand
# therefore reports everything:
#
# Invoke-ScriptAnalyzer -Path . -Recurse -Settings PSScriptAnalyzerSettings.psd1
#
# Generated from estate/standards/PSScriptAnalyzerSettings.psd1.
@{
IncludeDefaultRules = $true
ExcludeRules = @(
# Write-Host is the point of an interactive admin script: it writes to the
# console without putting anything on the pipeline, which is exactly what
# a progress line should do. This rule fires 285 times across the estate
# and is right about none of them.
'PSAvoidUsingWriteHost'
# Wants a byte-order mark on any file containing non-ASCII. That fights
# .editorconfig, which sets BOM-less UTF-8 everywhere, and it fights the
# tooling: Windows PowerShell 5.1's `-Encoding UTF8` writes a BOM whether
# or not one is wanted, and a stray BOM has already broken a consumer in
# this estate once. BOM-less UTF-8 is the decision; this rule disagrees
# with the decision rather than finding a defect.
'PSUseBOMForUnicodeEncodedFile'
)
Rules = @{
# Formatting. These only fire when the analyser is run with -Fix or in the
# editor's format-document; they are never Errors, so they never gate a
# commit. They are here so the editor formats consistently across repos.
PSUseConsistentIndentation = @{
Enable = $true
Kind = 'space'
IndentationSize = 4
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
}
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $false
CheckSeparator = $true
CheckParameter = $false
}
PSAlignAssignmentStatement = @{
Enable = $true
CheckHashtable = $true
}
PSUseCorrectCasing = @{ Enable = $true }
# Correctness and security. Nothing exotic - these are the rules whose
# findings have historically been real.
PSAvoidUsingInvokeExpression = @{ Enable = $true }
PSAvoidUsingPlainTextForPassword = @{ Enable = $true }
PSAvoidUsingConvertToSecureStringWithPlainText = @{ Enable = $true }
PSUsePSCredentialType = @{ Enable = $true }
PSAvoidUsingCmdletAliases = @{ Enable = $true; Allowlist = @() }
PSUseApprovedVerbs = @{ Enable = $true }
PSMisleadingBacktick = @{ Enable = $true }
PSUseDeclaredVarsMoreThanAssignments = @{ Enable = $true }
PSAvoidDefaultValueSwitchParameter = @{ Enable = $true }
PSUseCmdletCorrectly = @{ Enable = $true }
PSReservedCmdletChar = @{ Enable = $true }
PSReservedParams = @{ Enable = $true }
}
}