Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upModule exported variables should not be flagged with PSUseDeclaredVarsMoreThanAssignment #819
Comments
|
@dantraMSFT
It would be quite difficult to catch that via the ast since it means getting a runtime value, would a partial solution be better than no solution? |
|
+1 on the request. A partial solution -- by which I assume you mean a simple parse to locate an export that matches an assigned but otherwise unused variable -- would work for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)'