Query module MissingVarDecl

name
Missing variable declaration
description
If a variable is not declared as a local variable, it becomes a global variable by default, which may be unintentional and could lead to unexpected behavior.
kind
problem
problem.severity
warning
id
js/missing-variable-declaration
tags
reliability maintainability
precision
high

Imports

javascript

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

Predicates

accidentalGlobalIn

Gets an accidental global in f, that is, an undeclared global in f that is not live at the entry of f, meaning that it is always written before being read the first time.

candidateVariable

Gets an accidental global in f that is read at least once in reachable code.

getAccessIn

Gets an access to v in function f.

getFirstAccessIn

Gets the (lexically) first access to variable v in function f.

undeclaredGlobalIn

Gets an undeclared global in f, that is, a global variable that is accessed in f, but not declared in the same toplevel as f.