PSScriptAnalyzer
PSScriptAnalyzer copied to clipboard
PSPossibleIncorrectComparisonWithNull not checked inside DSC Configurations
Steps to reproduce
if (@() -eq $null) { 'true' } else { 'false' }
if (@() -ne $null) { 'true' } else { 'false' }
Configuration Test
{
if (@() -eq $null) { 'true' } else { 'false' }
if (@() -ne $null) { 'true' } else { 'false' }
}
Expected behavior
All 4 comparisons produce Warnings
Actual behavior
# Only the first two comparisons produce Warnings
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSPossibleIncorrectComparisonWithNull Warning test.ps1 1 $null should be on the left side of equality comparisons.
PSPossibleIncorrectComparisonWithNull Warning test.ps1 2 $null should be on the left side of equality comparisons.
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.1171
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.1171
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.20.0
Thank you! @VirtualEvan We are able to reproduce this and identified it as a bug, we are not sure however when we will get around to fixing this bug.