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
The PSScriptAnalyzer is a static code checker for PowerShell modules and scripts where it allows for creating custom rules in PowerShell.
Yet, there aren't any rules to check whether the custom rules are written according the best practices (which potentially could lead to pitfalls).
The examples at Creating custom rules could be improved for at least the known best practices:
There is a static value assigned for the RuleSuppressionID which will not help to differentiate between specific RuleName warnings. (I assume this just an example, but simple might misslead someone.)
For the later point, I think it should be possible to write a rule that checks whether there is a VariableExpressionAst (rather than a StringConstantExpressionAst, or nothing) assigned to the RuleSuppressionID property of the [Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord] object.
The text was updated successfully, but these errors were encountered:
1st one is not specific to custom rules and second is probably a good use for a custom rule, which a community member could publish as this is a narrow use cases as most PSSA users don't use custom rules in first place
The PSScriptAnalyzer is a static code checker for PowerShell modules and scripts where it allows for creating custom rules in PowerShell.
Yet, there aren't any rules to check whether the custom rules are written according the best practices (which potentially could lead to pitfalls).
The examples at Creating custom rules could be improved for at least the known best practices:
+=
) to build a collection(don't say here it it is ok for small collection, as you can't determine how big the collection will be at runtime.)
RuleSuppressionID
which will not help to differentiate between specificRuleName
warnings.(I assume this just an example, but simple might misslead someone.)
For the later point, I think it should be possible to write a rule that checks whether there is a
VariableExpressionAst
(rather than aStringConstantExpressionAst
, or nothing) assigned to theRuleSuppressionID
property of the[Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord]
object.The text was updated successfully, but these errors were encountered: