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
{{ message }}
Repository navigation
Global variables are erroneously reported as "never used" #1300
PowerShell extension reports global variables as assigned but not used when they are not used from within a .psm1 module file. However, global variables may be used by scripts outside that module importing it.
Expected Behaviour
Global variables should never be reported as being unused.
Actual Behaviour
PowerShell extension reports global variables as assigned but not used when they are not used from within a .psm1 module file.
I agree with you that global variables should be included from the analysis as that's their nature and there is a separate rule that discourages them anyway, so I'd be happy to accept a PR with such a change
I agree with you that global variables should be included from the analysis as that's their nature and there is a separate rule that discourages them anyway, so I'd be happy to accept a PR with such a change
Global variables are discouraged? What should be used in place of them?
Activity
bergmeister commentedon Sep 2, 2019
I agree with you that global variables should be included from the analysis as that's their nature and there is a separate rule that discourages them anyway, so I'd be happy to accept a PR with such a change
NapAlot commentedon Jan 7, 2021
I have this issue as well. it seems that The analyzer should be aware of $Global:var as being in the host script outside the function as $var.
NapAlot commentedon Jan 7, 2021
Global variables are discouraged? What should be used in place of them?
NapAlot commentedon Jan 7, 2021
I was able to resolve my issues by setting my $global: to $script: