Skip to content

Commit

Permalink
Fix HQRM with preview DscResource.ScriptAnalyzer Rules (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-hughes authored Nov 17, 2024
1 parent eba544d commit 8b170c8
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 69 deletions.
101 changes: 65 additions & 36 deletions .vscode/analyzersettings.psd1
Original file line number Diff line number Diff line change
@@ -1,44 +1,73 @@
@{
CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules'
CustomRulePath = @(
'.\output\RequiredModules\DscResource.AnalyzerRules'
'.\output\RequiredModules\Indented.ScriptAnalyzerRules'
)
IncludeDefaultRules = $true
IncludeRules = @(
IncludeRules = @(
# DSC Resource Kit style guideline rules.
'PSAvoidDefaultValueForMandatoryParameter',
'PSAvoidDefaultValueSwitchParameter',
'PSAvoidInvokingEmptyMembers',
'PSAvoidNullOrEmptyHelpMessageAttribute',
'PSAvoidUsingCmdletAliases',
'PSAvoidUsingComputerNameHardcoded',
'PSAvoidUsingDeprecatedManifestFields',
'PSAvoidUsingEmptyCatchBlock',
'PSAvoidUsingInvokeExpression',
'PSAvoidUsingPositionalParameters',
'PSAvoidShouldContinueWithoutForce',
'PSAvoidUsingWMICmdlet',
'PSAvoidUsingWriteHost',
'PSDSCReturnCorrectTypesForDSCFunctions',
'PSDSCStandardDSCFunctionsInResource',
'PSDSCUseIdenticalMandatoryParametersForDSC',
'PSDSCUseIdenticalParametersForDSC',
'PSMisleadingBacktick',
'PSMissingModuleManifestField',
'PSPossibleIncorrectComparisonWithNull',
'PSProvideCommentHelp',
'PSReservedCmdletChar',
'PSReservedParams',
'PSUseApprovedVerbs',
'PSUseCmdletCorrectly',
'PSUseOutputTypeCorrectly',
'PSAvoidGlobalVars',
'PSAvoidUsingConvertToSecureStringWithPlainText',
'PSAvoidUsingPlainTextForPassword',
'PSAvoidUsingUsernameAndPasswordParams',
'PSDSCUseVerboseMessageInDSCResource',
'PSShouldProcess',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUsePSCredentialType',
'PSAvoidDefaultValueForMandatoryParameter'
'PSAvoidDefaultValueSwitchParameter'
'PSAvoidInvokingEmptyMembers'
'PSAvoidNullOrEmptyHelpMessageAttribute'
'PSAvoidUsingCmdletAliases'
'PSAvoidUsingComputerNameHardcoded'
'PSAvoidUsingDeprecatedManifestFields'
'PSAvoidUsingEmptyCatchBlock'
'PSAvoidUsingInvokeExpression'
'PSAvoidUsingPositionalParameters'
'PSAvoidShouldContinueWithoutForce'
'PSAvoidUsingWMICmdlet'
'PSAvoidUsingWriteHost'
'PSDSCReturnCorrectTypesForDSCFunctions'
'PSDSCStandardDSCFunctionsInResource'
'PSDSCUseIdenticalMandatoryParametersForDSC'
'PSDSCUseIdenticalParametersForDSC'
'PSMisleadingBacktick'
'PSMissingModuleManifestField'
'PSPossibleIncorrectComparisonWithNull'
'PSProvideCommentHelp'
'PSReservedCmdletChar'
'PSReservedParams'
'PSUseApprovedVerbs'
'PSUseCmdletCorrectly'
'PSUseOutputTypeCorrectly'
'PSAvoidGlobalVars'
'PSAvoidUsingConvertToSecureStringWithPlainText'
'PSAvoidUsingPlainTextForPassword'
'PSAvoidUsingUsernameAndPasswordParams'
'PSDSCUseVerboseMessageInDSCResource'
'PSShouldProcess'
'PSUseDeclaredVarsMoreThanAssignments'
'PSUsePSCredentialType'

# Additional rules from the module ScriptAnalyzer
'PSUseConsistentWhitespace'
'UseCorrectCasing'
'PSPlaceOpenBrace'
'PSPlaceCloseBrace'
'AlignAssignmentStatement'
'AvoidUsingDoubleQuotesForConstantString'
'UseShouldProcessForStateChangingFunctions'

# Rules from the modules DscResource.AnalyzerRules
'Measure-*'

# Rules from the module Indented.ScriptAnalyzerRules
'AvoidCreatingObjectsFromAnEmptyString'
'AvoidDashCharacters'
'AvoidEmptyNamedBlocks'
'AvoidFilter'
'AvoidHelpMessage'
'AvoidNestedFunctions'
'AvoidNewObjectToCreatePSObject'
'AvoidParameterAttributeDefaultValues'
'AvoidProcessWithoutPipeline'
'AvoidSmartQuotes'
'AvoidThrowOutsideOfTry'
'AvoidWriteErrorStop'
'AvoidWriteOutput'
'UseSyntacticallyCorrectExamples'
)

}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added Indented.AnalyzerRules and config
- Use prerelease DscResource.ScriptAnalyzer

### Changed

- Move docs generation to separate task.
- Remove build.yml config not required.

### Fixed

- Fixed HQRM scriptanalyzer errors

## [0.19.0] - 2024-10-15

### Changed
Expand Down
32 changes: 19 additions & 13 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
@{
PSDependOptions = @{
PSDependOptions = @{
AddToPath = $true
Target = 'output\RequiredModules'
Parameters = @{
Repository = 'PSGallery'
}
}

InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.AnalyzerRules' = 'latest'
xDscResourceDesigner = 'latest'
'DscResource.Test' = 'latest'
InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.AnalyzerRules' = @{
Version = 'latest'
Parameters = @{
AllowPrerelease = $true
}
}
'Indented.ScriptAnalyzerRules' = 'latest'
xDscResourceDesigner = 'latest'
'DscResource.Test' = 'latest'

# Prerequisite modules for documentation.
'DscResource.DocGenerator' = 'latest'
Expand Down
23 changes: 7 additions & 16 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ BuildWorkflow:
- Build_Module_ModuleBuilder
- Build_NestedModules_ModuleBuilder
- Create_changelog_release_output
- Generate_Wiki_Content

docs:
- Generate_Conceptual_Help
- Generate_Markdown_For_Public_Commands
- Generate_External_Help_File_For_Public_Commands
- Clean_Markdown_Of_Public_Commands
- Generate_Wiki_Content
- Generate_Wiki_Sidebar
- Clean_Markdown_Metadata
- Package_Wiki_Content

pack:
- build
- docs
- package_module_nupkg

hqrmtest:
Expand Down Expand Up @@ -158,16 +159,6 @@ DscResource.DocGenerator:
- '\*(.+?)\*' # Match Italic (asterisk)
Publish_GitHub_Wiki_Content:
Debug: false
Generate_Wiki_Content:
MofResourceMetadata:
Type: MofResource
Category: Resources
ClassResourceMetadata:
Type: ClassResource
Category: Resources
CompositeResourceMetadata:
Type: CompositeResource
Category: Resources
Generate_Wiki_Sidebar:
Debug: false
AlwaysOverwrite: true
Debug: false
AlwaysOverwrite: true
3 changes: 2 additions & 1 deletion source/Public/Assert-ElevatedUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
function Assert-ElevatedUser
{
[CmdletBinding()]
param (
param
(
[Parameter()]
[ValidateNotNullOrEmpty()]
[System.String]
Expand Down
4 changes: 1 addition & 3 deletions source/Public/Set-DscMachineRebootRequired.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ function Set-DscMachineRebootRequired
#>
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
[CmdletBinding()]
param
(
)
param ()

$global:DSCMachineStatus = 1
}

0 comments on commit 8b170c8

Please sign in to comment.