PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

PSScriptAnalyzer incorrectly scopes variables in begin/process/end scriptblock

Open kborowinski opened this issue 8 years ago • 2 comments

PSScriptAnalyzer incorrectly adds scope to begin/process/end scriptblocks when it should treat them as one scope:

hashtable

kborowinski avatar Jul 29 '17 10:07 kborowinski

This also happens in the ForEach method:

$Script = @'
$A = @()
(1..2).ForEach{ $A += $_ }
$A
'@

Invoke-ScriptAnalyzer -ScriptDefinition $Script | Select -ExpandProperty Message

The variable 'A' is assigned but never used.

TimCurwick avatar Aug 01 '17 20:08 TimCurwick

Bug still exists today and it is very annoying.

desk7 avatar Mar 19 '23 16:03 desk7