Skip to content

Commit 40d5c00

Browse files
authored
Update tests to Pester 5 (#86)
1 parent 1fe9224 commit 40d5c00

21 files changed

Lines changed: 2935 additions & 1155 deletions

.vscode/analyzersettings.psd1

Lines changed: 104 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,112 @@
11
@{
22
CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules'
33
includeDefaultRules = $true
4-
IncludeRules = @(
5-
# DSC Resource Kit style guideline rules.
6-
'PSAvoidDefaultValueForMandatoryParameter',
7-
'PSAvoidDefaultValueSwitchParameter',
8-
'PSAvoidInvokingEmptyMembers',
9-
'PSAvoidNullOrEmptyHelpMessageAttribute',
10-
'PSAvoidUsingCmdletAliases',
11-
'PSAvoidUsingComputerNameHardcoded',
12-
'PSAvoidUsingDeprecatedManifestFields',
13-
'PSAvoidUsingEmptyCatchBlock',
14-
'PSAvoidUsingInvokeExpression',
15-
'PSAvoidUsingPositionalParameters',
16-
'PSAvoidShouldContinueWithoutForce',
17-
'PSAvoidUsingWMICmdlet',
18-
'PSAvoidUsingWriteHost',
19-
'PSDSCReturnCorrectTypesForDSCFunctions',
20-
'PSDSCStandardDSCFunctionsInResource',
21-
'PSDSCUseIdenticalMandatoryParametersForDSC',
22-
'PSDSCUseIdenticalParametersForDSC',
23-
'PSMisleadingBacktick',
24-
'PSMissingModuleManifestField',
25-
'PSPossibleIncorrectComparisonWithNull',
26-
'PSProvideCommentHelp',
27-
'PSReservedCmdletChar',
28-
'PSReservedParams',
29-
'PSUseApprovedVerbs',
30-
'PSUseCmdletCorrectly',
31-
'PSUseOutputTypeCorrectly',
32-
'PSAvoidGlobalVars',
33-
'PSAvoidUsingConvertToSecureStringWithPlainText',
34-
'PSAvoidUsingPlainTextForPassword',
35-
'PSAvoidUsingUsernameAndPasswordParams',
36-
'PSDSCUseVerboseMessageInDSCResource',
37-
'PSShouldProcess',
38-
'PSUseDeclaredVarsMoreThanAssignments',
39-
'PSUsePSCredentialType',
4+
IncludeRules = @(
5+
# DSC Community style guideline rules from the module ScriptAnalyzer.
6+
'PSAvoidDefaultValueForMandatoryParameter'
7+
'PSAvoidDefaultValueSwitchParameter'
8+
'PSAvoidInvokingEmptyMembers'
9+
'PSAvoidNullOrEmptyHelpMessageAttribute'
10+
'PSAvoidUsingCmdletAliases'
11+
'PSAvoidUsingComputerNameHardcoded'
12+
'PSAvoidUsingDeprecatedManifestFields'
13+
'PSAvoidUsingEmptyCatchBlock'
14+
'PSAvoidUsingInvokeExpression'
15+
'PSAvoidUsingPositionalParameters'
16+
'PSAvoidShouldContinueWithoutForce'
17+
'PSAvoidUsingWMICmdlet'
18+
'PSAvoidUsingWriteHost'
19+
'PSDSCReturnCorrectTypesForDSCFunctions'
20+
'PSDSCStandardDSCFunctionsInResource'
21+
'PSDSCUseIdenticalMandatoryParametersForDSC'
22+
'PSDSCUseIdenticalParametersForDSC'
23+
'PSMisleadingBacktick'
24+
'PSMissingModuleManifestField'
25+
'PSPossibleIncorrectComparisonWithNull'
26+
'PSProvideCommentHelp'
27+
'PSReservedCmdletChar'
28+
'PSReservedParams'
29+
'PSUseApprovedVerbs'
30+
'PSUseCmdletCorrectly'
31+
'PSUseOutputTypeCorrectly'
32+
'PSAvoidGlobalVars'
33+
'PSAvoidUsingConvertToSecureStringWithPlainText'
34+
'PSAvoidUsingPlainTextForPassword'
35+
'PSAvoidUsingUsernameAndPasswordParams'
36+
'PSDSCUseVerboseMessageInDSCResource'
37+
'PSShouldProcess'
38+
'PSUseDeclaredVarsMoreThanAssignments'
39+
'PSUsePSCredentialType'
4040

41+
# Additional rules from the module ScriptAnalyzer
42+
'PSUseConsistentWhitespace'
43+
'UseCorrectCasing'
44+
'PSPlaceOpenBrace'
45+
'PSPlaceCloseBrace'
46+
'AlignAssignmentStatement'
47+
'AvoidUsingDoubleQuotesForConstantString'
48+
'UseShouldProcessForStateChangingFunctions'
49+
50+
# Rules from the modules DscResource.AnalyzerRules
4151
'Measure-*'
52+
53+
# Rules from the module Indented.ScriptAnalyzerRules
54+
'AvoidCreatingObjectsFromAnEmptyString'
55+
'AvoidDashCharacters'
56+
'AvoidEmptyNamedBlocks'
57+
'AvoidFilter'
58+
'AvoidHelpMessage'
59+
'AvoidNestedFunctions'
60+
'AvoidNewObjectToCreatePSObject'
61+
'AvoidParameterAttributeDefaultValues'
62+
'AvoidProcessWithoutPipeline'
63+
'AvoidSmartQuotes'
64+
'AvoidThrowOutsideOfTry'
65+
'AvoidWriteErrorStop'
66+
'AvoidWriteOutput'
67+
'UseSyntacticallyCorrectExamples'
4268
)
4369

70+
<#
71+
The following types are not rules but parse errors reported by PSScriptAnalyzer
72+
so they cannot be excluded. They need to be filtered out from the result of
73+
Invoke-ScriptAnalyzer.
74+
75+
TypeNotFound - Because classes in the project cannot be found unless built.
76+
RequiresModuleInvalid - Because 'using module' in prefix.ps1 cannot be resolved as source file.
77+
#>
78+
ExcludeRules = @()
79+
80+
Rules = @{
81+
PSUseConsistentWhitespace = @{
82+
Enable = $true
83+
CheckOpenBrace = $true
84+
CheckInnerBrace = $true
85+
CheckOpenParen = $true
86+
CheckOperator = $false
87+
CheckSeparator = $true
88+
CheckPipe = $true
89+
CheckPipeForRedundantWhitespace = $true
90+
CheckParameter = $false
91+
}
92+
93+
PSPlaceOpenBrace = @{
94+
Enable = $true
95+
OnSameLine = $false
96+
NewLineAfter = $true
97+
IgnoreOneLineBlock = $false
98+
}
99+
100+
PSPlaceCloseBrace = @{
101+
Enable = $true
102+
NoEmptyLineBefore = $true
103+
IgnoreOneLineBlock = $false
104+
NewLineAfter = $true
105+
}
106+
107+
PSAlignAssignmentStatement = @{
108+
Enable = $true
109+
CheckHashtable = $true
110+
}
111+
}
44112
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- General code cleanup
2626
- Updated Classifications ID reference with additional potential classification GUIDs
2727
- Updated module to use latest Sampler files and modules.
28+
- Generated stubs for `UpdateServices` module.
29+
- Updated scriptanalyzer settings to latest.
30+
- Rename `Tests` directory to `tests`.
31+
- Updated Unit tests to Pester 5 DscCommunity format.
2832

2933
### Added
3034

0 commit comments

Comments
 (0)