VS Code is throwing warnings on some of the code checks where we have $foo -eq $null or -ne $null. This code might not do what we expect. Example here:
$object = @(1, $null, 2, $null)
# "not safe" comparison with $null, perhaps a mistake
if ($object -eq $null) {
# -eq gets @($null, $null) which is evaluated to $true by if
'This is called.'
}
# safe comparison with $null
if ($null -eq $object) {
'This is not called.'
}
VS Code is throwing warnings on some of the code checks where we have $foo -eq $null or -ne $null. This code might not do what we expect. Example here:
https://raw.githubusercontent.com/nightroman/PowerShellTraps/master/Basic/Comparison-operators-with-collections/looks-like-object-is-null.ps1