PowerShell / PowerShell/PSScriptAnalyzer
Module exported variables should not be flagged with PSUseDeclaredVarsMoreThanAssignment
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
Repro: In a module, define and assign a variable then export it using Export-ModuleMember -Variable
$MyVariable = 'some value'
Export-ModuleMember -Variable MyVariable
Expected: Invoke-ScriptAnalyzer does not flag the variable as unused.
Actual:
file: 'file:MyModule.psm1'
severity: 'Warning'
message: 'The variable 'MyVariable' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the MyModule.psm1 example: assign MyVariable and export it with Export-ModuleMember -Variable. Trace the PSUseDeclaredVarsMoreThanAssignments rule and its existing tests, then verify that an exported module variable is no longer reported as assigned but never used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100