Query module HeterogeneousComparison

name
Comparison between inconvertible types
description
An equality comparison between two values that cannot be meaningfully converted to the same type will always yield ‘false’, and an inequality comparison will always yield ‘true’.
kind
problem
problem.severity
warning
id
js/comparison-between-incompatible-types
tags
reliability correctness external/cwe/cwe-570 external/cwe/cwe-571
precision
high

Imports

javascript

Provides classes for working with JavaScript programs, as well as JSON, YAML and HTML.

Predicates

comparisonOperands

Holds if left and right are the left and right operands, respectively, of nd, which is a comparison.

convertedOperandType

Gets a type that operand, which is an operand of comparison parent, could be converted to at runtime.

getDescription

Gets a user friendly description of e, if such a description exists.

getDescription

Gets a user friendly description of e, default is the result if no such description exists.

getTypeDescription

Gets the simpler message of message1 and message2 guided by the corresponding complexity1 and complexity2.

hasImplicitConversionMethod

Holds if av may have a toString or valueOf method.

implicitlyConvertedOperand

Holds if operand is an operand of the non-strict equality test or relational operator parent, and may have a toString or valueOf method.

isHeterogeneousComparison

Holds if left and right are operands of comparison cmp having types leftTypes and rightTypes, respectively, but there is no common type they coerce to.

isInitialParameterUse

Holds if e directly uses a parameter’s initial value as passed in from the caller.

isPseudoKeyword

Holds if name is a variable name that programmers consider a keyword.

nonStrictOperandType

Gets a type of operand, which is an operand of the non-strict equality test or relational operator parent.

strictEqualityOperandType

Gets a type of operand, which is an operand of the strict equality test eq.

whitelist

Holds if e is an expression that should not be considered in a heterogeneous comparison.