PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

Bring back deprecated rules

Open kilasuit opened this issue 3 years ago • 2 comments

Historically PSScriptAnalyzer has had a number of rules that have been deprecated & then removed from the available set of rules, one such example is AvoidUninitializedVariables

I propose that we bring them back, but publish them contained in a separate module so that others could still use them if they choose to do so.

This realistically shouldn't equate for much additional engineering work & would provide a better mechanism for rule development & deprecation in future whilst not loosing potentially useful rules in specific cases.

kilasuit avatar Jun 09 '21 12:06 kilasuit

but publish them contained in a separate module so that others could still use them if they choose to do so.

I'm not sure that's something that PSScriptAnalyzer supports -- loading other binary rules on-demand is something that has been discussed on and off, but I'm not sure it's currently something that the code will allow you to do.

Historically PSScriptAnalyzer has had a number of rules that have been deprecated & then removed

It would probably be helpful if you could identify those rules and point to their previous implementations.

This realistically shouldn't equate for much additional engineering work

I've marked it up-for-grabs.

rjmholt avatar Jun 09 '21 15:06 rjmholt

I was going to request this as a suggestion but as I see here this is something that existed and was removed?

This will fail at runtime, I wish to get a warning before runtime:

Set-StrictMode -Version 3.0
$Foo -gt 5
# InvalidOperation: The variable '$Foo' cannot be retrieved because it has not been set.

This will run successfully, but I still want to get a warning that it was not initialized in the scope:

Set-StrictMode -Version 3.0

$Foo = 10
function Test-Scoping {
    [CmdletBinding()]
    param ()
    
    $Foo -gt 5
}
Test-Scoping

ili101 avatar Jan 26 '23 14:01 ili101