29
29
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck -Scope CurrentUser
30
30
}
31
31
32
+ - name : Create PSScriptAnalyzer settings
33
+ shell : pwsh
34
+ run : |
35
+ $settings = @'
36
+ @{
37
+ Severity = @('Warning')
38
+ IncludeRules = @(
39
+ 'PSUseFullyQualifiedCmdletNames',
40
+ 'PSAvoidDefaultValueSwitchParameter',
41
+ 'PSAvoidUsingCmdletAliases',
42
+ 'PSAvoidAssignmentToAutomaticVariable',
43
+ 'PSAvoidDefaultValueForMandatoryParameter',
44
+ 'PSAvoidExclaimOperator',
45
+ 'PSAvoidGlobalAliases',
46
+ 'PSAvoidGlobalFunctions',
47
+ 'PSAvoidGlobalVars',
48
+ 'PSAvoidLongLines',
49
+ 'PSAvoidNullOrEmptyHelpMessageAttribute',
50
+ 'PSAvoidOverwritingBuiltInCmdlets',
51
+ 'PSReservedCmdletChar',
52
+ 'PSReservedParams',
53
+ 'PSAvoidSemicolonsAsLineTerminators',
54
+ 'PSAvoidShouldContinueWithoutForce',
55
+ 'PSAvoidTrailingWhitespace',
56
+ 'PSAvoidUsingDeprecatedManifestFields',
57
+ 'PSAvoidUsingDoubleQuotesForConstantString',
58
+ 'PSMisleadingBacktick',
59
+ 'PSMissingModuleManifestField',
60
+ 'PSPlaceOpenBrace',
61
+ 'PSPossibleIncorrectComparisonWithNull',
62
+ 'PSPossibleIncorrectUsageOfAssignmentOperator',
63
+ 'PSPossibleIncorrectUsageOfRedirectionOperator',
64
+ 'PSUseApprovedVerbs',
65
+ 'PSUseCmdletCorrectly',
66
+ 'PSUseCompatibleCmdlets',
67
+ 'PSUseConsistentIndentation',
68
+ 'PSUseConsistentWhitespace',
69
+ 'PSUseDeclaredVarsMoreThanAssignments',
70
+ 'PSUseLiteralInitializerForHashtable',
71
+ 'PSUseOutputTypeCorrectly',
72
+ 'PSUseProcessBlockForPipelineCommand',
73
+ 'PSShouldProcess',
74
+ 'PSUseShouldProcessForStateChangingFunctions',
75
+ 'PSUseSingularNouns',
76
+ 'PSUseSupportsShouldProcess',
77
+ 'PSUseToExportFieldsInManifest',
78
+ 'PSUseUsingScopeModifierInNewRunspaces'
79
+ )
80
+ ExcludeRules = @(
81
+ 'PSUseCorrectCasing',
82
+ 'PSUseCompatibleCommands',
83
+ 'PSAlignAssignmentStatement',
84
+ 'PSAvoidUsingEmptyCatchBlock',
85
+ 'PSReviewUnusedParameter',
86
+ 'PSAvoidInvokingEmptyMembers',
87
+ 'PSAvoidMultipleTypeAttributes',
88
+ 'PSAvoidUsingPositionalParameters',
89
+ 'PSUseBOMForUnicodeEncodedFile',
90
+ 'PSAvoidUsingUsernameAndPasswordParams',
91
+ 'PSAvoidUsingAllowUnencryptedAuthentication',
92
+ 'PSAvoidUsingBrokenHashAlgorithms',
93
+ 'PSAvoidUsingComputerNameHardcoded',
94
+ 'PSAvoidUsingConvertToSecureStringWithPlainText',
95
+ 'PSAvoidUsingInvokeExpression',
96
+ 'PSAvoidUsingPlainTextForPassword',
97
+ 'PSAvoidUsingWMICmdlet',
98
+ 'PSAvoidUsingWriteHost',
99
+ 'PSUseCompatibleSyntax',
100
+ 'PSUseCompatibleTypes',
101
+ 'PSPlaceCloseBrace',
102
+ 'PSProvideCommentHelp',
103
+ 'PSUsePSCredentialType',
104
+ 'PSUseUTF8EncodingForHelpFile',
105
+ 'PSDSCDscExamplesPresent',
106
+ 'PSDSCDscTestsPresent',
107
+ 'PSDSCReturnCorrectTypesForDSCFunctions',
108
+ 'PSDSCUseIdenticalMandatoryParametersForDSC',
109
+ 'PSDSCUseIdenticalParametersForDSC',
110
+ 'PSDSCStandardDSCFunctionsInResource',
111
+ 'PSDSCUseVerboseMessageInDSCResource'
112
+ )
113
+ IncludeDefaultRules = $true
114
+ RecurseCustomRulePath = $false
115
+ Rules = @{
116
+ PSUseFullyQualifiedCmdletNames = @{
117
+ Enabled = $true
118
+ }
119
+ }
120
+ }
121
+ '@
122
+ $settings | Out-File -FilePath "${{ github.workspace }}/PSScriptAnalyzerSettings.psd1" -Encoding UTF8
123
+
32
124
- name : Run PSScriptAnalyzer
33
125
shell : pwsh
34
126
run : |
@@ -40,10 +132,11 @@ jobs:
40
132
41
133
$allFiles = @($scriptFiles) + @($moduleFiles)
42
134
$issuesFound = $false
135
+ $settingsPath = "${{ github.workspace }}/PSScriptAnalyzerSettings.psd1"
43
136
44
137
foreach ($file in $allFiles) {
45
138
Write-Host "`nAnalyzing: $($file.FullName)" -ForegroundColor Yellow
46
- $results = Invoke-ScriptAnalyzer -Path $file.FullName -Severity Warning,Error
139
+ $results = Invoke-ScriptAnalyzer -Path $file.FullName -Settings $settingsPath
47
140
48
141
if ($results) {
49
142
$issuesFound = $true
0 commit comments