You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you declare an env variable and not use in current script, PSScriptAnalyzer show the PSUseDeclaredVarsMoreThanAssignments warning.
Specific use case: I set the $Env:GIT_WORK_TREE for git configuration; PSScriptAnalyzer show: The variable 'GIT_WORK_TREE' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)
The text was updated successfully, but these errors were encountered:
@robdesideri Thanks for reporting the case, it is a known issue that PSUseDeclaredVarsMoreThanAssignments can produce false positives in certain cases. However I canot repro your problem using PSScriptanalyzer 1.16.1 and PowerShell 5.1: Invoke-ScriptAnalyzer -ScriptDefinition "$Env:GIT_WORK_TREE=$gitWorkTree" does not return a warning. Please provide more details. Also note that another way of setting environment variables is [System.Environment]::SetEnvironmentVariable($string)
When you declare an
env
variable and not use in current script, PSScriptAnalyzer show thePSUseDeclaredVarsMoreThanAssignments
warning.Specific use case: I set the
$Env:GIT_WORK_TREE
for git configuration; PSScriptAnalyzer show:The variable 'GIT_WORK_TREE' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)
The text was updated successfully, but these errors were encountered: