CodeQL library for JavaScript
Search

Module ExprHasNoEffect

Provides classes and predicates for the ‘js/useless-expression’ query.

Import path

import Expressions.ExprHasNoEffect

Imports

DOMProperties

Provides predicates for working with the DOM type hierarchy.

javascript

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

xUnit

Provides classes for working with xUnit.js tests.

Predicates

hasNoEffect

Holds if the expression e should be reported as having no effect.

inVoidContext

Holds if e appears in a syntactic context where its value is discarded.

isDeclaration

Holds if e is of the form x; or e.p; and has a JSDoc comment containing a tag. In that case, it is probably meant as a declaration and shouldn’t be flagged by this query.

isGetterProperty

Holds if there exists a getter for a property called name anywhere in the program.

isIndirectEval

Holds if c is an indirect eval call of the form (dummy, eval)(...), where dummy is some expression whose value is discarded, and which simply exists to prevent the call from being interpreted as a direct eval.

isReceiverSuppressingCall

Holds if c is a call of the form (dummy, e[p])(...), where dummy is some expression whose value is discarded, and which simply exists to prevent the call from being interpreted as a method call.

noSideEffects

Holds if evaluating e has no side effects (except potentially allocating and initializing a new object).

Classes

GetterPropertyAccess

A property access that may invoke a getter.