-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSScriptAnalyzerSettings.psd1
More file actions
85 lines (79 loc) · 4.14 KB
/
PSScriptAnalyzerSettings.psd1
File metadata and controls
85 lines (79 loc) · 4.14 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
79
80
81
82
83
84
85
# PSScriptAnalyzer settings for this repo.
# Reference: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/README.md#settings-support-in-scriptanalyzer
@{
Severity = @('Information', 'Error', 'Warning')
IncludeRules = @(
'PSAlignAssignmentStatement', # CodeFormatting
'PSAvoidDefaultValueSwitchParameter', # CmdletDesign, PSGallery
'PSAvoidGlobalVars', # PSGallery
'PSAvoidUsingCmdletAliases', # PSGallery
'PSAvoidUsingComputerNameHardcoded', # PSGallery
'PSAvoidUsingConvertToSecureStringWithPlainText', # ScriptSecurity
'PSAvoidUsingEmptyCatchBlock', # PSGallery
'PSAvoidUsingInvokeExpression', # PSGallery (consider using Invoke-Command with script block: `Invoke-Command -ScriptBlock { Write-Host "Hello" }`, instead of Invoke-Expression)
'PSAvoidUsingPlainTextForPassword', # PSGallery
'PSAvoidUsingPositionalParameters', # PSGallery
'PSAvoidUsingUserNameAndPasswordParams', # ScriptSecurity
'PSAvoidUsingWMICmdlet', # PSGallery
# 'PSAvoidUsingWriteHost', # ScriptingStyle. No concerns using `Write-Host` because it is used as informational output in scripts and provides additional options, like color, that Write-Output and Write-Informational do not provide.
# 'PSDSC*', # PSGallery. Do not expect desired state config scripts to be used. Specific rule names can be found with: `Get-ScriptAnalyzerRule | Where-Object { $_.RuleName -like "PSDSC*" }`
'PSMissingModuleManifestField', # CmdletDesign, PSGallery
'PSPlaceCloseBrace', # CodeFormatting
'PSPlaceOpenBrace', # CodeFormatting
'PSProvideCommentHelp', # ScriptingStyle
'PSReservedCmdletChar', # CmdletDesign, PSGallery
'PSReservedParams', # CmdletDesign, PSGallery
'PSShouldProcess', # CmdletDesign, PSGallery
'PSUseApprovedVerbs', # CmdletDesign, PSGallery
'PSUseCmdletCorrectly', # PSGallery
'PSUseConsistentIndentation', # CodeFormatting
'PSUseConsistentWhitespace', # CodeFormatting
'PSUseCorrectCasing', # CodeFormatting
'PSUseDeclaredVarsMoreThanAssignments', # PSGallery
'PSUsePSCredentialType', # PSGallery
'PSUseShouldProcessForStateChangingFunctions', # CmdletDesign, PSGallery
'PSUseShouldProcessForStateChangingFunctions', # PSGallery
'PSUseSingularNouns' # CmdletDesign, PSGallery
)
# CodeFormattingOTBS rules, a.k.a K&R
# https://github.com/PowerShell/PSScriptAnalyzer/blob/58c44234d44dfd0db35bb532906963e08fde8621/Engine/Settings/CodeFormattingOTBS.psd1
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $false
IgnoreOneLineBlock = $true
NoEmptyLineBefore = $false
}
PSUseConsistentIndentation = @{
Enable = $true
Kind = 'space'
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
IndentationSize = 4
}
PSUseConsistentWhitespace = @{
Enable = $true
CheckInnerBrace = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckPipe = $true
CheckPipeForRedundantWhitespace = $false
CheckSeparator = $true
CheckParameter = $false
IgnoreAssignmentOperatorInsideHashTable = $true
}
PSAlignAssignmentStatement = @{
Enable = $true
CheckHashtable = $true
}
PSUseCorrectCasing = @{
Enable = $true
}
}
}