Closed
Description
Before submitting a bug report:
- Make sure you are able to repro it on the latest released version
- Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
Wrote a short blog post about it: https://evotec.xyz/the-curious-case-of-null-should-be-on-the-left-side-of-equality-comparisons-psscriptanalyzer/
But the code is as below:
$Object1 = @{
Name = 'Test1'
Status = 1
}
$Object2 = @{
Name = 'Tests2'
Status = $null
}
$Array = @($Object1, $Object2)
$Test1 = While ($Array.Status -ne $null) {
$true
foreach ($A in $Array) {
$A.Status = $null
}
}
$Test1
$Test2 = While ($null -ne $Array.Status) {
$true
foreach ($A in $Array) {
$A.Status = $null
}
}
$Test2
It will never end for $Test2.
Expected behavior
No tip for the Array.
Actual behavior
Tip that tells the user to fix the code.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.1
1.18.0
Metadata
Metadata
Assignees
Labels
No labels