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
Hi, I've got a legacy script which I've started running through PSScriptAnalyzer, and I've got a bunch of global variables which I'm gradually refactoring away. However, one of them is proving difficult to deal with so I'd like to suppress the PSAvoidGlobalVars error on just that one for now, while leaving the others still erroring to remind me I need to come back and fix them later.
I don't really want to exclude the rule entirely, so I've tried this...
I'm guessing I need to add the attribute to a script-level param block and scope / target the variable somehow, but I'm not sure what Scope or Target to use...
@mikeclayton I don't think PSSA supports to limit the scope of syppresion only to a certain variable. The Scope parameter would be e.g. script, function, or class and the Target allows filtering of functions that should suppress this rule. You would need to put the declaration therefore in a function or script of its own, similar to how I do it here.
At the moment, ideas are also floating around in issue 849 to enhance suppression to be able to enable/disable suppresions just for a few lines (similar to ReSharper warnings).
Hi, I've got a legacy script which I've started running through PSScriptAnalyzer, and I've got a bunch of global variables which I'm gradually refactoring away. However, one of them is proving difficult to deal with so I'd like to suppress the PSAvoidGlobalVars error on just that one for now, while leaving the others still erroring to remind me I need to come back and fix them later.
I don't really want to exclude the rule entirely, so I've tried this...
myScript.ps1
... but it doesn't seem to suppress the error for
$global:myGlobalVar2
.Is there another way to do this?
The text was updated successfully, but these errors were encountered: