Skip to content

Commit 5d09837

Browse files
authored
OpticalDiskDrive prevent exception on unmanageable device condition - Fixes #289 (#290)
* Fix issue #289 and update pipeline files to latest version
1 parent 173d684 commit 5d09837

15 files changed

+1659
-446
lines changed

.vscode/analyzersettings.psd1

+109-38
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,115 @@
11
@{
2-
CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules'
3-
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',
2+
CustomRulePath = @(
3+
'./output/RequiredModules/DscResource.AnalyzerRules'
4+
'./output/RequiredModules/Indented.ScriptAnalyzerRules'
5+
)
6+
IncludeDefaultRules = $true
7+
IncludeRules = @(
8+
# DSC Community style guideline rules from the module ScriptAnalyzer.
9+
'PSAvoidDefaultValueForMandatoryParameter'
10+
'PSAvoidDefaultValueSwitchParameter'
11+
'PSAvoidInvokingEmptyMembers'
12+
'PSAvoidNullOrEmptyHelpMessageAttribute'
13+
'PSAvoidUsingCmdletAliases'
14+
'PSAvoidUsingComputerNameHardcoded'
15+
'PSAvoidUsingDeprecatedManifestFields'
16+
'PSAvoidUsingEmptyCatchBlock'
17+
'PSAvoidUsingInvokeExpression'
18+
'PSAvoidUsingPositionalParameters'
19+
'PSAvoidShouldContinueWithoutForce'
20+
'PSAvoidUsingWMICmdlet'
21+
'PSAvoidUsingWriteHost'
22+
'PSDSCReturnCorrectTypesForDSCFunctions'
23+
'PSDSCStandardDSCFunctionsInResource'
24+
'PSDSCUseIdenticalMandatoryParametersForDSC'
25+
'PSDSCUseIdenticalParametersForDSC'
26+
'PSMisleadingBacktick'
27+
'PSMissingModuleManifestField'
28+
'PSPossibleIncorrectComparisonWithNull'
29+
'PSProvideCommentHelp'
30+
'PSReservedCmdletChar'
31+
'PSReservedParams'
32+
'PSUseApprovedVerbs'
33+
'PSUseCmdletCorrectly'
34+
'PSUseOutputTypeCorrectly'
35+
'PSAvoidGlobalVars'
36+
'PSAvoidUsingConvertToSecureStringWithPlainText'
37+
'PSAvoidUsingPlainTextForPassword'
38+
'PSAvoidUsingUsernameAndPasswordParams'
39+
'PSDSCUseVerboseMessageInDSCResource'
40+
'PSShouldProcess'
41+
'PSUseDeclaredVarsMoreThanAssignments'
42+
'PSUsePSCredentialType'
43+
44+
# Additional rules from the module ScriptAnalyzer
45+
'PSUseConsistentWhitespace'
46+
'UseCorrectCasing'
47+
'PSPlaceOpenBrace'
48+
'PSPlaceCloseBrace'
49+
'AlignAssignmentStatement'
50+
'AvoidUsingDoubleQuotesForConstantString'
51+
'UseShouldProcessForStateChangingFunctions'
4052

53+
# Rules from the modules DscResource.AnalyzerRules
4154
'Measure-*'
55+
56+
# Rules from the module Indented.ScriptAnalyzerRules
57+
'AvoidCreatingObjectsFromAnEmptyString'
58+
'AvoidDashCharacters'
59+
'AvoidEmptyNamedBlocks'
60+
'AvoidFilter'
61+
'AvoidHelpMessage'
62+
'AvoidNestedFunctions'
63+
'AvoidNewObjectToCreatePSObject'
64+
'AvoidParameterAttributeDefaultValues'
65+
'AvoidProcessWithoutPipeline'
66+
'AvoidSmartQuotes'
67+
'AvoidThrowOutsideOfTry'
68+
'AvoidWriteErrorStop'
69+
'AvoidWriteOutput'
70+
'UseSyntacticallyCorrectExamples'
4271
)
4372

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

.vscode/settings.json

+24-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
"powershell.codeFormatting.whitespaceAroundOperator": true,
88
"powershell.codeFormatting.whitespaceAfterSeparator": true,
99
"powershell.codeFormatting.ignoreOneLineBlock": false,
10-
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline",
10+
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
1111
"powershell.codeFormatting.preset": "Custom",
1212
"powershell.codeFormatting.alignPropertyValuePairs": true,
13+
"powershell.codeFormatting.useConstantStrings": true,
14+
"powershell.developer.bundledModulesPath": "${cwd}/output/RequiredModules",
15+
"powershell.scriptAnalysis.settingsPath": "/.vscode/analyzersettings.psd1",
16+
"powershell.scriptAnalysis.enable": true,
1317
"files.trimTrailingWhitespace": true,
18+
"files.trimFinalNewlines": true,
1419
"files.insertFinalNewline": true,
15-
"powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1",
16-
"powershell.scriptAnalysis.enable": true,
1720
"files.associations": {
1821
"*.ps1xml": "xml"
1922
},
23+
"cSpell.dictionaries": [
24+
"powershell"
25+
],
2026
"cSpell.words": [
2127
"COMPANYNAME",
2228
"ICONURI",
@@ -32,7 +38,21 @@
3238
"pscmdlet",
3339
"steppable"
3440
],
41+
"cSpell.ignorePaths": [
42+
".git"
43+
],
3544
"[markdown]": {
45+
"files.trimTrailingWhitespace": true,
3646
"files.encoding": "utf8"
37-
}
47+
},
48+
"powershell.pester.useLegacyCodeLens": false,
49+
"pester.testFilePath": [
50+
"[tT]ests/[qQ][aA]/*.[tT]ests.[pP][sS]1",
51+
"[tT]ests/[uU]nit/**/*.[tT]ests.[pP][sS]1",
52+
"[tT]ests/[uU]nit/*.[tT]ests.[pP][sS]1"
53+
],
54+
"pester.runTestsInNewProcess": true,
55+
"pester.pesterModulePath": "./output/RequiredModules/Pester",
56+
"powershell.pester.codeLens": true,
57+
"pester.suppressCodeLensNotice": true,
3858
}

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
### Fixed
9+
10+
- OpticalDiskDriveLetter:
11+
- Some operating systems report the optical disk in the Win32_CDROMDrive list,
12+
but a volume that matches either the DeviceId or DriveLetter can not be found.
13+
This caused an `Cannot bind argument to parameter 'DevicePath' because it is an empty string.`
14+
exception to occur in the `Test-OpticalDiskCanBeManaged`. Prevented this
15+
exception from occuring by marking disk as not manageable - Fixes [Issue #289](https://github.com/dsccommunity/StorageDsc/issues/289).
16+
- Azure DevOps Build Pipeline:
17+
- Update pipeline files to use latest DSC Community pattern and sampler tasks.
18+
819
## [6.0.0] - 2024-03-19
920

1021
### Added

GitVersion.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mode: ContinuousDelivery
2-
next-version: 4.9.0
3-
major-version-bump-message: '\s?(breaking|major|breaking\schange)'
4-
minor-version-bump-message: '\s?(add|feature|minor)'
2+
next-version: 4.1.0
3+
major-version-bump-message: '(breaking\schange|breaking)\b'
4+
minor-version-bump-message: '(adds?|minor)\b'
55
patch-version-bump-message: '\s?(fix|patch)'
66
no-bump-message: '\+semver:\s?(none|skip)'
77
assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}'
@@ -21,6 +21,7 @@ branches:
2121
increment: Patch
2222
regex: (hot)?fix(es)?[\/-]
2323
source-branches: ['master']
24+
2425
ignore:
2526
sha: []
2627
merge-message-formats: {}

RequiredModules.psd1

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@
1717
'Sampler.GitHubTasks' = 'latest'
1818
MarkdownLinkCheck = 'latest'
1919
'DscResource.Test' = 'latest'
20-
'DscResource.AnalyzerRules' = 'latest'
21-
'DscResource.DocGenerator' = 'latest'
22-
'DscResource.Common' = 'latest'
2320
xDscResourceDesigner = 'latest'
21+
22+
# Build dependencies needed for using the module
23+
'DscResource.Common' = 'latest'
24+
25+
# Analyzer rules
26+
'DscResource.AnalyzerRules' = 'latest'
27+
'Indented.ScriptAnalyzerRules' = 'latest'
28+
29+
# Prerequisite modules for documentation.
30+
'DscResource.DocGenerator' = 'latest'
31+
PlatyPS = 'latest'
2432
}

0 commit comments

Comments
 (0)