GoLand 2020.3 Help

Code Inspections in JavaScript and TypeScript

This topic lists all GoLand code inspections available in JavaScript and TypeScript.

You can toggle specific inspections or change their severity level on the Editor | Inspections page of the Settings/Preferences Ctrl+Alt+S.

DOM issues

InspectionDescriptionDefault Severity
Call to 'document.write()'

Reports method calls to document.write() or document.writeln(). Most uses of these calls are better performed using explicit DOM calls such as getElementByID() and createElement(). Additionally, the write() and writeln() calls will not work with XML DOMs, including DOMs for XHTML if viewed as XML. This can result in difficulty to point out bugs.

Disabled
Platform detection

Reports common JavaScript patterns for detecting the browser or operating system in which the script is being run. In addition to pointing out non-portable constructs, these platform detection patterns are often incomplete and easily fooled. For most cases, detection of individual environment features is preferable to attempting to detect the entire platform. Patterns detected include document.all, document.layers, navigator.userAgent, navigator.oscpu, navigator.appName, navigator.appCodeName, and navigator.platform

Disabled
Use of 'innerHTML' property

Reports JavaScript accesses to DOM nodes as text using the innerHTML property. Most uses of innerHTML are better performed using explicit DOM calls such as getElementByID() and createElement(). Additionally, innerHTML will not work with XML DOMs, including DOMs for XHTML if viewed as XML. This can lead to difficult to diagnose bugs.

Disabled
XHTML incompatibilities

Reports common JavaScript DOM patterns which may present problems with XHTML documents. In particular, the patterns detected will behave completely differently depending on whether the document is loaded as XML or HTML. This can result in subtle bugs where script behaviour is dependent on the MIME-type of the document, rather than its content. Patterns detected include document.body, document.images, document.applets, document.links, document.forms, and document.anchors.

Disabled

Imports and dependencies

InspectionDescriptionDefault Severity
Imports validation

Validates names and paths in ECMAScript import declarations.

Weak Warning Weak warning
Mismatched dependencies in package.json

Reports dependencies in package.json that are not installed or don't match the specified version range.

Warning Warning
Missing React import with JSX

When using JSX, it's usually required to have import from React in the file scope. Otherwise, the code may not compile properly. The inspection is disabled in projects with React 17 because the version no longer requires the React import.

Weak Warning Weak warning
Missing module dependency

Checks whether the module in the require() call or import statement exists, whether it is listed in package.json dependencies, and whether it is locally installed.

Suggests installing the module and/or including it into package.json.

For require() calls, works only in files in the scope of Node.js Core JavaScript library.

Weak Warning Weak warning
Unused ES6 / TypeScript imports

Reports unused JavaScript or TypeScript import bindings or specifiers. The validation works in ES6 and TypeScript files.

Warning Warning

Code quality tools

InspectionDescriptionDefault Severity
ESLint

Runs the ESLint linter.

The highlighting is based on the rule severity specified in the ESLint configuration file. Uncheck "Use rule severity from the configuration file" to use the same severity configured in this inspection for all ESLint rules.

Disabled
JSHint

Runs JSHint validator for specified JavaScript file.

Disabled
Standard code style

Reports errors according to JavaScript Standard Style.

The severity level of the inspection is applied only for the 'Inspect code...' action.

Disabled
TSLint

Runs TSLint- a linter for TypeScript.

The highlighting is based on the rule severity specified in the TSLint configuration file. Uncheck "Use rule severity from the configuration file" to use the same severity configured in this inspection for all TSLint rules.

Disabled

Assignment issues

InspectionDescriptionDefault Severity
Assignment replaceable with operator assignment

Reports assignment operations which can be replaced by operator assignment. Using operator assignment may be clearer, and theoretically more performant.

Disabled
Assignment to 'for' loop parameter

Reports assignments to variables declared as a for loop parameter. While occasionally intended, this construct can be extremely confusing, and is often the result of a programmer error.

Disabled
Assignment to function parameter

Reports assignments to function parameters. It also reports attempts to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a programmer error.

Disabled
Assignment used as condition

Reports an assignment being used as the condition of an if, while, for or do statement. While occasionally intended, this usage is confusing, and often indicates a typo (= instead of == ).

Warning Warning
Nested assignment

Reports assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.

Disabled
Result of assignment used

Reports assignment expressions where the result of the assignment is used in a containing expression. Such assignments are often indications of coding errors such as using = instead of ==. Moreover, they can result in confusion due to order of operations, as evaluation of the assignment may effect the outer expression in unexpected ways.

Expressions in parentheses are ignored.

Disabled
Variable is assigned to itself

Reports assignments of the form x = x. These are pointless, and usually indicate programmer error.

Warning Warning

Potentially confusing code constructs

InspectionDescriptionDefault Severity
Confusing floating point literal

Reports floating point numbers which do not have a decimal point, numbers before the decimal point, and numbers after the decimal point. Such literals may be confusing, and violate several coding standards.

Disabled
Confusing sequence of '+' or '-'

Reports suspicions combinations of + or - characters in JavaScript code (e.g. a+++b. While legal, such sequences are confusing, and may have their semantics changed through changes in whitespace.

Disabled
Execution of dynamically generated JavaScript

Reports calls to the eval(), setTimeout(), and setInterval() functions, or allocation of a Function object. These functions are used to execute arbitrary strings of JavaScript text, often dynamically generated. This can be very confusing, and may be a security risk.

Disabled
Magic number

Reports "magic numbers", i.e. literal numeric constants used without declaration. "Magic numbers" can result in code whose intention is extremely unclear, and may result in errors if a "magic number" is changed in one code location but not another. The numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 0.0 and 1.0 are not reported by this inspection.

Disabled
Negated 'if' statement

Reports if statements which have an else branch and a negated condition. Flipping the order of the if and else branches will usually increase the clarity of such statements.

Disabled
Negated conditional expression

Reports conditional expressions whose conditions are negated. Flipping the order of the conditional expression branches will usually increase the clarity of such statements.

Disabled
Nested conditional expression

Reports ternary conditional expressions contained within other ternary conditions. Such nested conditionals may be extremely confusing, and best replaced by more explicit conditional logic.

Disabled
Nested function

Reports functions nested inside other functions. While JavaScript allows functions to be nested, such constructs may be confusing. Additionally, nested functions are prone to cause difficult-to-diagnose memory leaks in certain browsers, including Microsoft Internet Explorer.

Use the checkbox below to prevent this inspection from reporting anonymous nested functions.

Disabled
Overly complex arithmetic expression

Reports arithmetic expressions with too many terms. Such expressions may be confusing and bug-prone.

Use the field provided below to specify the maximum number of terms allowed in an arithmetic expression.

Disabled
Overly complex boolean expression

Reports boolean expressions with too many terms. Such expressions may be confusing and bug-prone.

Use the field provided below to specify the maximum number of terms allowed in an arithmetic expression.

Disabled
Pointless arithmetic expression

Reports pointless arithmetic expressions. Such expressions include adding or subtracting zero, multiplying by zero or one, division by one, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.

Warning Warning
Result of increment or decrement used

Reports increment (++) or decrement (--) expressions where the result of the assignment is used in a containing expression. Such assignments can result in confusion due to order of operations, as evaluation of the assignment may effect the outer expression in unexpected ways.

Disabled
Statement with empty body

Reports if, while, for, and with statements whose bodies are empty. While occasionally useful, such statements are often the result of typos, and may cause confusion.

Use the checkbox below to select whether statements whose bodies are empty block statements will be reported by this inspection.

Warning Warning
Unnecessary 'block' statement

Reports unnecessary block statements. Block statements that are not used as the body of if, for, while, do, with, or try statements, or as the body of a function declaration are reported. Since JavaScript blocks do not introduce new scopes as is common in Java and other languages, free-standing block statements may be the result of code confusion, and may result in subtle bugs.

Disabled
Use of 'caller' property

Reports uses of the caller property in a JavaScript function. Use of this property to access the stack frame of the calling method can be extremely confusing, and result in subtle bugs.

Warning Warning

Node.js

InspectionDescriptionDefault Severity
Unresolved Node.js APIs

Suggests configuring coding assistance for Node.js, e.g. 'require' and/or core modules ('path', 'http', 'fs', etc.).

See https://nodejs.org/api/ for the complete list.

Warning Warning

Unit testing

InspectionDescriptionDefault Severity
Highlight failure line in test code

This inspection highlights failed method calls or assertions in tests.

Warning Warning

Validity issues

InspectionDescriptionDefault Severity
'this' expression which references the global object

Reports this expressions occurring outside of object literals or constructor bodies. Such this expressions are legal JavaScript, and reference the top-level "global" JavaScript object, but are largely useless.

Warning Warning
Attempt to assign to const or readonly variable

Checks that constant or readonly variable is being reassigned.

Error Error
Expression statement which is not assignment or call

Reports expression statements which are not assignments or calls. Such statements have no obvious semantics, and are normally the result of programmer error.

Weak Warning Weak warning
Function with inconsistent returns

Reports functions which return a value in some circumstances and return without a value in others. While legal, such code almost certainly represents a programming error.

Disabled
Octal integer

Reports deprecated octal integer literals prefixed with '0' and not '0o'.
It is an error to use such literals in modern ECMAScript code, and it is an error to use them in strict mode.
You can force this inspection for ES5 and ES3 language levels by ticking the 'Warn about obsolete octal literals in ES5- code' checkbox in the inspection settings.

Error Error
Referencing 'arguments' outside of function

a

Checks that arguments references are inside a function body.

Error Error
Reserved word used as name

Reports JavaScript reserved words being used as a name. The JavaScript specification reserves a number of words which are currently not used as keywords. Using those words as identifiers may result in broken code if later versions of JavaScript start using them as keywords.

Warning Warning
String literal which breaks HTML parsing

Reports string literals which contain the sequence </. Such strings are legal JavaScript, but may result in incorrect parsing of any HTML the JavaScript is embedded in.

Disabled

Async code and promises

InspectionDescriptionDefault Severity
Missing await for an async function call

Missing await for an async function call results in having a Promise where a value was expected.

When the 'Report for promises in return statements' checkbox is checked, this inspection will also suggest adding 'await' in return statements.
While this is generally not necessary, it gives two main benefits.
The first one is that you won't forget to add 'await' when surrounding your code with try-catch.
The second one is that having explicit 'await' helps V8 runtime to provide async stack traces.

Weak Warning Weak warning
Possibly async function

Highlights usages of await in functions that were possibly intended to be async but are missing the async modifier. While it is possible to use await as an identifier, it is likely that it was intended to be used as an operator and the containing function should be made async.

Weak Warning Weak warning
Redundant 'await' expression

Reports redundant await usages, such as await await, or awaiting a non-promise result.
When the 'Report for promises' checkbox is checked, this inspection will also suggest removing 'await' before promises when applicable (in return statements, and with Promise.resolve/reject).
While this is not generally necessary, removing 'await' in such contexts gives you two problems.
The first one is that surrounding your code with try-catch and forgetting to add 'await' will change code semantics, and you may fail to notice that.
The second one is that not having explicit 'await' may prevent the V8 runtime from providing async stack traces.

Weak Warning Weak warning
Result of method call returning a promise is ignored

Reports function calls that return a Promise that is not later used. These are usually unintended and indicate an error.

Weak Warning Weak warning
Top-level 'await' expression

Highlights usages of top-level await -expressions. While the new 'top-level async' proposal is on its way, currently it is still illegal to use await outside async functions.

Disabled

Data flow

InspectionDescriptionDefault Severity
Redundant local variable

Reports unnecessary local variables, which add nothing to the comprehensibility of a function. Variables caught include local variables which are immediately returned, local variables that are immediately assigned to another variable and then not used, and local variables which always have the same value as another local variable or parameter.

Use the checkbox below to have this inspection ignore variables which are immediately returned or thrown. Some coding styles suggest using such variables for clarity and ease of debugging.

Warning Warning
Reuse of local variable

Reports where local variables are "reused", overwriting their values with new values unrelated to their original use. Such local variable reuse may be confusing, as the intended semantics of the local variable may vary with each use. It may also be prone to bugs, if code changes result in values that were thought to be overwritten actually being live. It is good practices to keep variable lifetimes as short as possible, and not reuse local variables for the sake of brevity.

Disabled

TypeScript

InspectionDescriptionDefault Severity
Abstract class constructor can be made protected

Suggests to make the constructor of an abstract class protected (because it is useless to have it public).

Weak Warning Weak warning
Duplicate union or intersection type component

Checks union and intersection types for duplicates

Warning Warning
Equality operator may cause type coercion

Reports usages of equality operators which may cause unexpected type coercions. It is considered a good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

Depending on the option selected, this will either highlight:

  • All usages of == and != operators.

  • All usages except comparison with null. Some code styles allow using x == null as a replacement for x === null || x === undefined.

  • Only suspicious expressions, such as: == or != comparisons to 0, '', null, true, false, or undefined.

Disabled
Explicit member types

Highlights type annotations that do not match the current code style for explicit types.

Type declarations are not necessary when the type inferred from the context exactly matches the type annotation, for example:

var pi: number = 3.14

In some cases it is preferable to always have explicit types - this saves from accidental type changes and makes code more explicit.

Info No highlighting, only fix
Field is assigned only in the constructor and can be made readonly

If a private field is assigned only in the constructor, it can be made readonly.

Weak Warning Weak warning
Generic type mismatch

Checks that a corresponding type argument is passed when a generic type is used in a function, interface or class declaration

Error Error
Missing augmentation import

Checks that current file imports the augmentation module.

Info No highlighting, only fix
Missing option in tsconfig.json

Checks that required options are enabled in tsconfig.json, e.g. when using React JSX in .tsx files, the TypeScript configuration file contains 'jsx: "react"'.

Warning Warning
Redundant type argument for a generic type

Checks type arguments for redundancy when a reference provides the type with default values

Weak Warning Weak warning
Reference to a UMD global

Report the use of references to a UMD global if the current file is a module.

Weak Warning Weak warning
Required TypeScript library is not included in tsconfig.json

Checks that the TypeScript library files required for the symbol are listed under the 'lib' compiler option in tsconfig.json.

Error Error
Suspicious parameter assignment in constructor

Warns against a common mistake in TypeScript code, when a class field is declared as a constructor parameter, and then this parameter is assigned.
In this case, the corresponding field won't be assigned, only the local parameter value is modified.

Warning Warning
Type mismatch in 'any' type context

Checks TypeScript called function parameters, return values, assigned expressions to be of correct type in any type context.

Weak Warning Weak warning
Unresolved TypeScript function

Checks that TypeScript called functions are valid.

Weak Warning Weak warning
Unresolved TypeScript variable

Checks that TypeScript referenced variables and fields are valid.

Weak Warning Weak warning
Variable type is narrowed by a type guard

Highlights variable usages where variable type is narrowed by a type guard. Note that severity level doesn't affect this inspection.

Warning Warning
tsconfig.json validation

Validates consistency of 'paths', 'checkJs' and 'extends' in tsconfig.json files.

Warning Warning

Probable bugs

InspectionDescriptionDefault Severity
'for' loop where update or condition does not use loop variable

Reports for loops where the condition or update does not use the for loop variable.

Disabled
Comparison of expressions having incompatible types

Checks that operands in comparisons have compatible types in JavaScript files. Operands of types without possible common values are reported.

Weak Warning Weak warning
Comparison with NaN

Checks code for comparisons with NaN. Comparisons like expr == NaN or expr === NaN are always evaluated to false.

Warning Warning
Consecutive commas in array literal

Checks that array literal doesn't contain consecutive commas. Skipped element takes undefined value, but it could be done unintentionally, e.g. when commas are at the end of one line and at the beginning of the following.

Warning Warning
Constructor returns primitive value

Checks that function recognized as constructor does not return primitive values. When called with new, this value will be lost and object will be returned instead. To avoid warnings, you can explicitly specify function's return type with @return tag.

Disabled
Division by zero

Reports division by zero or remainder by zero.

Disabled
Infinite loop statement

Reports for, while, or do statements which can only exit by throwing an exception. While such statements may be correct, they are often a symptom of coding errors.

Warning Warning
Infinite recursion

Reports functions which must either recurse infinitely or throw an exception. Functions reported by this inspection can not return normally.

Warning Warning
Possibly incorrect target of indexed property access

Reports potentially invalid indexed property access such as Array[1]. The validation works in JavaScript, html, or jsp files.

Warning Warning
Potentially invalid constructor usage

Reports potentially invalid constructor function usages such as: using non constructor in new, using constructor's prototype and constructor call without new. Constructor function assumed to have upper case name (optional) or have explicit JSDoc @constructor tag. The validation works in JavaScript, html or jsp files.

Warning Warning
Potentially invalid reference to 'this' from closure

Checks for this to be the same in closure and in outer context. The validation works in JavaScript, html, or jsp files.

Warning Warning
Potentially invalid reference to 'this' of a class from closure

Warns against a common mistake of trying to reference a member of an ECMAScript class via this. qualifier in a nested function that is not a lambda.
this in a nested function that is not a lambda is the function's own 'this' and doesn't relate to the outer class.

Warning Warning
Result of object allocation ignored

Reports object allocation where the result of the object allocated is ignored. Such allocation expressions are legal JavaScript, but are usually either inadvertent, or evidence of a very odd object initialization strategy.

Disabled
Suspicious '=+' assignment

Reports assignments in form 'a =+ b'. In most cases, assignments of form 'a =+ b' are typos, and the correct option is 'a += b'.

Warning Warning
Suspicious name combination

Reports assignments and function calls where the name of the variable to which a value is assigned or the function parameter does not seem to match the name of the value assigned to it. For example:

var x = 0; var y = x;
or
var x = 0, y = 0; var rc = new Rectangle(y, x, 20, 20);
The configuration pane allows to specify the names which should not be used together: the error is reported if the parameter name or assignment target name contains words from one group and the name of the assigned or passed variable contains words from a different group.

Warning Warning
Suspicious usage of 'bind' with arrow function

Warns if bind is used together with arrow function.
Since arrow functions use lexical this, bind call will have no effect on them.
Please read more here.

Warning Warning
Typeof comparing with non-standard value

Reports when literal string in a comparing with typeof is not one of the standard types: undefined, object, boolean, number, string, function or symbol.

Warning Warning

Control flow issues

InspectionDescriptionDefault Severity
'for' loop may be replaced by 'while' loop

Reports for loops which contain neither initialization or update components, and can thus be replaced by simpler while statements.

Use the checkbox below if you wish this inspection to ignore for loops with trivial or non-existent conditions.

Disabled
'if' statement with identical branches

Reports if statements with identical then and else branches. Such statements are almost certainly programmer error.

Disabled
'if' statement with too many branches

Reports if statements with too many branches. Such statements may be confusing, and are often the sign of inadequate levels of design abstraction.

Use the field below to specify the maximum number of branches expected.

Disabled
Conditional expression with identical branches

Reports ternary conditional expressions with identical then and else branches. Such statements are almost certainly programmer error.

Disabled
Constant conditional expression

Reports conditional expressions of the form true? result1: result2 or false? result1: result2. These expressions sometimes occur as the result of automatic refactorings, and may obviously be simplified.

Warning Warning
Duplicate condition in 'if' statement

Reports duplicate conditions in different branches of an if statement. While it may rarely be the desired semantics, duplicate conditions usually represent programmer oversight.

Disabled
Loop statement that doesn't loop

Reports for, while and do statements whose bodies are guaranteed to execute at most once. Normally, this is an indication of a bug.

Warning Warning
Object is 'null' or 'undefined'

Reports errors caused by invoking a method, accessing a property or calling a function on an object that is undefined or null.

Warning Warning
Pointless statement or boolean expression

Reports pointless or pointlessly complicated boolean expressions or statements.

Warning Warning
Redundant 'if' statement

Reports if statements which can be simplified to single assignment or return statements. For example:

if (foo()) { return true; } else { return false; } (foo()) { if (foo()) { return true; } else { return false; } true; } if (foo()) { return true; } else { return false; } { if (foo()) { return true; } else { return false; } false; }
can be simplified to
return foo(); foo();

Warning Warning
Redundant conditional expression

Reports conditional expressions of the form condition ?true:false or condition ?false:true. These expressions may be safely simplified to condition or ! condition, respectively.

Warning Warning
Tail recursion

Reports tail recursion, that is when a function calls itself as its last action before returning. Tail recursion can always be replaced by looping, which will be considerably faster. Some JavaScript engines perform this optimization, while others do not. Thus, tail recursive solutions may have considerably different performance characteristics on different environments.

Disabled
Unnecessary 'continue' statement

Reports unnecessary continue statements at the end of loops. These statements may be safely removed.

Warning Warning
Unnecessary 'return' statement

Reports unnecessary return statements. Unnecessary return statements are those which return no value and occur just before the function would have "fallen through" the bottom. These statements may be safely removed.

Warning Warning
Unnecessary label

Reports unused labels.

Warning Warning
Unnecessary label on 'break' statement

Reports labelled break statements whose labels may be removed without changing the flow of control.

Warning Warning
Unnecessary label on 'continue' statement

Reports labelled continue statements whose labels may be removed without changing the flow of control.

Warning Warning
Unreachable code

Reports code which can never be executed. Such code almost certainly represents a programming error

Warning Warning
Unsound type guard check

typeof x type guard can be unsound in one of the following two cases:

  1. typeof x never corresponds to the specified value (e.g., typeof x === 'number' when x has type 'string | boolean')

  2. typeof x always corresponds to the specified value (e.g., typeof x === 'string' when x has type 'string')


x instanceof A type guard can be unsound in one of the following two cases:
  1. Type of x is not related to A

  2. Type of x is A or a subtype of A

Warning Warning

Try statement issues

InspectionDescriptionDefault Severity
'continue' or 'break' inside 'finally' block

Reports break or continue statements inside of finally blocks. While occasionally intended, such statements are very confusing, may mask exceptions thrown, and tremendously complicate debugging.

Warning Warning
'return' inside 'finally' block

Reports return statements inside of finally blocks. While occasionally intended, such return statements may mask exceptions thrown, and tremendously complicate debugging.

Warning Warning
'throw' inside 'finally' block

Reports throw statements inside of finally blocks. While occasionally intended, such throw statements may mask exceptions thrown, and tremendously complicate debugging.

Warning Warning
Empty 'catch' block

Reports empty catch blocks. Empty catch blocks are a sign that errors are simply being ignored, rather than properly handled.

Disabled
Empty 'finally' block

Reports empty finally blocks. Empty finally blocks are usually the result of a coding error.

Disabled
Empty 'try' block

Reports empty try blocks. Empty try blocks are usually the result of a coding error.

Disabled
Exception used for local control-flow

Reports throw statements whose exceptions are always caught by containing try statements. Using throw statements as a "goto" to change the local flow of control is likely to be confusing.

Warning Warning
Unused 'catch' parameter

Reports catch parameters that are unused in their corresponding blocks. This inspection will not report catch parameters named "ignore" or "ignored".

Use the checkbox below to disable this inspection for catch blocks with comments.

Disabled

Naming conventions

InspectionDescriptionDefault Severity
Class naming convention

Reports classes and functions annotated with JSDoc @constructor or @class tags whose names are either too short, too long, or do not follow the specified regular expression pattern.

Use the fields provided below to specify minimum length, maximum length and regular expression expected for classes names. (Regular expressions are in standard java.util.regex format.)

Disabled
Function naming convention

Reports functions whose names are either too short, too long, or do not follow the specified regular expression pattern.

Use the fields provided below to specify minimum length, maximum length and regular expression expected for function names. (Regular expressions are in standard java.util.regex format.)

Disabled
Function parameter naming convention

Reports function parameters whose names are either too short, too long, or do not follow the specified regular expression pattern.

Use the fields provided below to specify minimum length, maximum length and regular expression expected for local variables names. (Regular expressions are in standard java.util.regex format.)

Disabled
Identifiers with non-ASCII symbols

Reports names containing non-ASCII symbols.

If 'Allow only ASCII names' option is used, reports all names containing non-ASCII symbols.
Otherwise reports all names, containing both ASCII and non-ASCII symbols.

Warning Warning
Local variable naming convention

Reports local variables whose names are either too short, too long, or do not follow the specified regular expression pattern.

Use the fields provided below to specify minimum length, maximum length and regular expression expected for local variables names. (Regular expressions are in standard java.util.regex format.)

Disabled

Flow type checker

InspectionDescriptionDefault Severity
Code is not covered by Flow

Checks that JavaScript code is covered by the Flow type checker. To use this inspection, the Flow executable must be configured in Settings | Languages & Frameworks | JavaScript

Disabled
Flow errors

Reports errors from Flow in Inspect code.

Disabled
Flow flag is misplaced

Checks that the // @flow flag is located on the top of the file – otherwise this file will not be checked by Flow.

Warning Warning
Missing .flowconfig

Checks that there’s a .flowconfig file in the project that covers a JavaScript file with the // @flow flag.

Warning Warning

Function metrics

InspectionDescriptionDefault Severity
Function with more than three negations

Reports functions with three or more negation operations (! or != ). Such functions may be unnecessarily confusing.

Disabled
Function with multiple loops

Reports functions containing multiple loop statements.

Disabled
Function with multiple return points

Reports functions with multiple return points. Some coding standards warn against functions with multiple returns, as they may make functions more difficult to understand and maintain.

Disabled
Function with too many parameters

Reports functions with too many parameters. Functions with too many parameters are often an indication of design weakness.

Use the field provided below to specify the maximum acceptable number of parameters a function might have.

Disabled
Overly complex function

Reports functions that have too high cyclomatic complexity. Cyclomatic complexity is basically a measurement of the number of branching points in a function. Functions with too high a cyclomatic complexity may be confusing and difficult to test.

Use the field provided below to specify the maximum acceptable cyclomatic complexity a function might have.

Disabled
Overly long function

Reports overly long functions. Function length is calculated by counting up the number of non-empty statements in the function. Functions that are too long are error-prone, and difficult to test.

Use the field provided below to specify the maximum acceptable number of statements a function might have.

Disabled
Overly nested function

Reports functions whose bodies are contain statements too deeply nested within other statements. Functions with too much statement nesting may be confusing, and are a good sign that refactoring may be necessary.

Use the field provided below to specify the maximum acceptable nesting depth a function might have.

Disabled

Code style issues

InspectionDescriptionDefault Severity
Braces around arrow function body can be removed

Reports arrow functions where the body contains exactly one statement and can be converted to concise syntax without braces.

let incrementer = (x) => {return x + 1}; to

let incrementer = (x) => x + 1;

Info No highlighting, only fix
Chained equality

Reports chained equality comparisons (i.e. a==b==c ). Such comparisons are confusing.

Disabled
Chained function call

Reports function calls whose target is another function call.

Disabled
Constant on left side of comparison

Reports on comparison operations with constant values on their left-hand side. Some coding conventions specify that constants should be on the right-hand side of comparisons.

Disabled
Constant on right side of comparison

Reports on comparison operations with constant values on their right-hand side. Some coding conventions specify that constants should be on the left-hand side of comparisons.

Disabled
Nested function call

Reports function calls used as arguments to another function call.

Disabled
Non-block statement body

Reports if, while, for, and with statements whose bodies are not block statements. While such statements are legal JavaScript, it is usually safer for downstream maintenance to use the code blocks for statement bodies.

Disabled
Undefined property assignment

Reports assignments to undefined properties of explicitly type-annotated variables.

Weak Warning Weak warning
Unnecessary parentheses

Reports parentheses when they are redundant.

In expressions: var x = ((1) + 2) + 3

Arrow function argument lists: var incrementer = (x) => x + 1

TypeScript and Flow type declarations: type Card = (Suit & Rank) | (Suit & Number)

Info No highlighting, only fix
Unterminated statement

Reports statements that may be erroneously not terminated by a semicolon or a newline.

If 'terminate statements with semicolons' is selected in Editor | Code Style | JavaScript or TypeScript - Punctuation, reports all statements which do not end with a semicolon. While line-breaks may be used instead of semicolons to terminate JavaScript statements, some coding styles prefer the semicolon for consistency with the other languages.

Disabled
Variable declarations are not at the scope start

Checks that local variables declared with var are at the top of a function scope.

By default, variable declarations are always moved ("hoisted") invisibly to the top of their containing scope when the code is executed. Therefore, having them defined at the top of the scope helps represent this behavior in the code.

Disabled

General

InspectionDescriptionDefault Severity
#-private fields access without explicit 'this.'

Checks for #x -like access to private fields. Such syntax was allowed in the early versions of the specification draft, but is no longer a valid syntax. In the most recent versions of the draft, only the syntax with explicit 'this.' qualifier is valid.

Error Error
@private and @protected members accessibility

Checks that JavaScript members marked with @private and @protected tags are visible in current context.

Warning Warning
Closure compiler syntax

Checks code for warnings implied by Google Closure Compiler annotations. This includes correct usage of @abstract, @interface and @implements tags.

Warning Warning
Deprecated JavaScript symbol

Checks for using deprecated functions and variables. The validation works in JavaScript, html, or jsp files.

Weak Warning Weak warning
Destructuring properties with the same key can be merged

Reports multiple destructuring properties with identical keys that can be merged

Weak Warning Weak warning
Duplicate JavaScript declaration

Checks that declarations are declared once in current scope. The validation works in JavaScript, TypeScript, html or jsp files.

Warning Warning
File references validation

Reports unresolved file references in JavaScript files, including CommonJS and AMD modules references.

Warning Warning
Implicitly declared global JavaScript variable

Checks that variables are declared explicitly with a var statement. The validation works in JavaScript, html or jsp files.

Weak Warning Weak warning
Import can be shortened

Reports ES6 imports whose from part can be shortened by importing the parent directory.

Warning Warning
JQuery usage efficiency

Checks that jQuery selectors are used in an efficient way. It warns about duplicated selectors which could be cached and optionally about attribute and pseudo-selectors usage.

Warning Warning
JSDoc comment matches function signature

Checks that parameters defined within JSDoc comments match the function's actual parameters, i.e. have the same names and quantity.

Warning Warning
JavaScript general errors

This inspection reports basic syntax issues and inconsistencies with language specification. Examples are invalid usages of keywords, incompatible numeric format usage or multiple parameters to getters/setters.
Generally, such errors must always be reported and shouldn't be disabled. But in some cases, like issues due to dynamic nature of JavaScript, usage of not yet supported language features, or bugs in IDE's checker, it may be handy to disable reporting these very basic errors.

Error Error
Method can be static

Checks for ActionScript, JavaScript and TypeScript methods which may safely be made static. A method may be static if it does not reference any of its class' non static methods and non static fields and is not overridden in a sub class.

Use the first checkbox below to inspect only private methods.

Warning Warning
Mismatched query and update of collection

Reports collection fields or variables whose contents are either queried and not updated, or updated and not queried. Such mismatched queries and updates are pointless, and may indicate either dead code or a typographical error.

Query methods are automatically detected, based on whether they return something or a callback is passed. Use the table below to specify which methods are update methods.

Warning Warning
Non-strict mode used

Checks that JavaScript files are in strict mode.

Disabled
Primitive type object wrapper used

Checks for improper usage of wrappers for primitive types. Also, warning will be produced when property of primitive type is modified, as assigned value will be lost.

Warning Warning
Property can be replaced with shorthand

Highlights and provides fixes to convert object properties to ES6 shorthand style.

var obj = {foo:foo} to

var obj = {foo}

Info No highlighting, only fix
React JSX syntax

Highlights usages of React JSX tags in JavaScript code.

Disabled
Redundant nesting in template literal

Reports nested instances of strings and template literals. Such instances can be inlined into the containing template string.

For example, `Hello, ${`Brave ${"New"}`} ${"World"}!` can be simplified to `Hello, Brave New World!`

Weak Warning Weak warning
Referencing mutable variable from closure

Checks for accessing mutable variables in nested functions. The validation works in JavaScript, html, or jsp files.

Warning Warning
Signature mismatch

Checks JavaScript called function arguments, return values, assigned expressions to be of correct type. The validation works in JavaScript, html or jsp files.

Weak Warning Weak warning
Syntax errors and unresolved references in JSDoc

Validates syntax and references in JavaScript/ActionScript documentation comments (JSDoc/ASDoc).

Warning Warning
There is no locally stored library for the HTTP link.

Checks that URL of an external JavaScript library is associated with a locally stored file used for code completion and navigation.
Use 'Download library' quick fix (Alt+Enter) to solve the problem.

Warning Warning
Type mismatch

Checks that called function parameters, return values and assigned expressions are of the correct type. The validation works in JavaScript, html or jsp files.

Weak Warning Weak warning
Unfiltered for..in loop

Checks for unfiltered for-in loops. The use of this construct results in processing inherited or unexpected properties. You need to filter own properties with hasOwnProperty() method. The validation works in JavaScript, html or jsp files.

Warning Warning
Unnecessary semicolon

Reports unneeded semicolons. The validation works in JavaScript, html or jsp files.

Warning Warning
Unneeded last comma in array literal

Reports when a trailing comma is used in array literals.

The warning is reported only when the JavaScript language version is set to JavaScript 1.8.5, ECMAScript 3 or 5.1.

Trailing commas in arrays are allowed according to these specifications, however, some browsers might throw an error when a trailing comma is used.

You can configure formatting options for trailing commas in Code Style | JavaScript or TypeScript | Punctuation.

Warning Warning
Unneeded last comma in object literal

Reports when a trailing comma is used in object literals.

The warning is reported only when the JavaScript language version is set to JavaScript 1.8.5, ECMAScript 3 or 5.1.

Trailing commas in object literals are allowed according to these specifications, however, some browsers might throw an error when a trailing comma is used.

You can configure formatting options for trailing commas in Code Style | JavaScript or TypeScript | Punctuation.

Warning Warning
Unresolved Ext JS xtype

Checks that Ext JS xtype references have corresponding class.

Warning Warning
Unresolved JavaScript function

Checks that called functions are valid. The validation works in JavaScript, html or jsp files.

Weak Warning Weak warning
Unresolved JavaScript variable

Checks that referenced variables and fields are valid. The validation works in JavaScript, html or jsp files.

Weak Warning Weak warning
Unresolved React component

Reports the use of unresolved React components. As a fix, suggests adding a missing import statement if the referenced component is defined in the project or its dependencies or creating a new component with this name.

The template for a new component can be modified in Editor | File and Code Templates.

Weak Warning Weak warning
Use of possibly unassigned property in a static initializer

Reports when a class member initializer references another non-hoisted class member that could be not initialized yet.

Class members initialization happens consequently for fields, thus, a field cannot reference another field declared later.

Warning Warning
Variable declaration can be merged with the first assignment to the variable

This inspection suggests to move variables closer to their usages joining with the initializer expression If a variable is declared without an initializer, and it is used in the code much further or in a single nested scope, such variable may be joined with the first assignment as an initializer.

Info No highlighting, only fix
Webpack configuration validation

Validates options in the webpack configuration file (which name should start with `webpack`, e.g. `webpack.config.js`) against webpack Options Schema.

Disable this inspection to turn off validation and code completions inside the configuration object.

Warning Warning

Switch statement issues

InspectionDescriptionDefault Severity
'default' not last case in 'switch'

Reports switch statements where the default case comes before some other case.
Having the default mixed with other cases causes confusion. The best practice is to have it as the very last case.

Disabled
'switch' statement has missing branches

Reports switch statements on a variable of enum or union type when the statement covers not all the value options from the type.

Info No highlighting, only fix
'switch' statement has no 'default' branch

Reports switch statements without default clause in case when not all possible values are enumerated.

Info No highlighting, only fix
'switch' statement is redundant and can be replaced

Reports unnecessary switch statements. Warns on switch statement with an empty body, only one case branch, or only single default branch.

Info No highlighting, only fix
Duplicate case label

Reports duplicated case labels on switch statements. Such switch statements are normally an indication of programmer error.

Warning Warning
Fallthrough in 'switch' statement

Reports cases where control can proceed from one branch of a switch statement to the next. Such "fall-through" is often a result of programmer error, for example, a missing break or return.

Warning Warning
Nested 'switch' statement

Reports switch statements which are nested in other switch statements. Such nested switch statements can be very confusing, particularly if proper indenting is not followed.

Disabled
Text label in 'switch' statement

Reports labelled statements inside of switch statements. While occasionally intended, this construction is often the result of a typo.

switch (x) { case 1: case2: //typo! case 3: break ; } (x) { switch (x) { case 1: case2: //typo! case 3: break ; } 1: case2: //typo! switch (x) { case 1: case2: //typo! case 3: break ; } 3: switch (x) { case 1: case2: //typo! case 3: break ; } ; }

Disabled
Unreachable 'case' branch of a 'switch' statement

Reports case branches of a switch statement that are unreachable in current context

Warning Warning
Variable is declared and being used in different 'case' clauses

Reports variables that are declared in one case clause of a switch statement, and are used in a different case clause of the same statement. For block-scope variables, this results in a ReferenceError being thrown. For var -variables, it signifies a potential error. This inspection can be disabled for var -variables if you use this pattern intentionally.

Warning Warning

ECMAScript 6 migration aids

InspectionDescriptionDefault Severity
'for..in' is used instead of 'for..of'

Converts for..in loops on arrays to for..of loops.
for..of loops, introduced in ECMAScript 6, iterate over iterable objects. For arrays, this construction should be preferred to for..in, since it is executed only for array values and not for array object's properties.

Info No highlighting, only fix
'let' used where it could be a 'const'

Reports let declarations that can be made const.

Info No highlighting, only fix
'module.exports' is used instead of 'export'

Reports when module.export is used and helps to replace it with the export or export default statement.

Please note that a quick-fix for converting module.export into export is not available for module.export inside functions or statements, because export statements can only be at the top level of a module.

Info No highlighting, only fix
'require()' is used instead of 'import'

Reports when require() is used and helps to replace the require() call with the import statement.

Enable Convert require() inside inner scopes with Fix all action to convert all require() calls inside the nested functions and statements when using the Fix all action.

Please note that converting the require() statements inside inner scopes to the import statements may cause changes in the semantics of the code. Import statements are static module dependencies and are hoisted, which means that they are moved to the top of the current module. require() calls load modules dynamically. They can be executed conditionally and their scope is defined by the expression in which they are used.
Clear Convert require() inside inner scopes with Fix all action option to prevent any changes in these complex cases when using Fix all action.

Info No highlighting, only fix
'var' used instead of 'let' or 'const'

Reports var declarations that are used instead of let or const.
Both let and const are block-scoped and behave more strictly.

It helps to replace all var declarations with let or const declarations, depending on value semantics. Declarations might be moved to the top of the function or before the first usage of the variable to avoid Reference errors.
Check Conservatively convert var with Fix all action option to prevent any changes in these complex cases when using Fix all action.

Weak Warning Weak warning
Function expression is used instead of arrow function

Helps to replace function expressions with arrow functions.

Info No highlighting, only fix
Indexed 'for' loop could be replaced with 'for..of'

Converts indexed for loops on arrays to for..of loops.
for..of loops, introduced in ECMAScript 6, iterate over iterable objects.

Info No highlighting, only fix
String concatenation is used instead of string template

This inspection highlights string concatenations that can be replaced with a template string.

Info No highlighting, only fix

Bitwise operation issues

InspectionDescriptionDefault Severity
Bitwise operator usage

Reports suspicious usages of bitwise AND (" & ") and OR (" | ") operators. Usually it is a common typo and user expect a result according to the boolean operations AND (" && ") and OR (" || ").

Warning Warning
Incompatible bitwise mask operation

Reports bitwise mask expressions which are guaranteed to evaluate to true or false. Expressions checked are of the form (var & constant1) == constant2 or (var | constant1) == constant2, where constant1 and constant2 are incompatible bitmask constants.

Warning Warning
Pointless bitwise expression

Reports pointless bitwise expressions. Such expressions include and ing with zero, or ing by zero, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.

Disabled
Shift operation by inappropriate constant

Reports shift operations where the value shifted by is constant and outside of the reasonable range. Integer shift operations outside of the range 0..31 are reported. Shifting by negative or overly large values is almost certainly a coding error.

Warning Warning

Unused symbols

InspectionDescriptionDefault Severity
Unused assignment

Checks JavaScript for unused assignments. The validation works in JavaScript, ActionScript, HTML and JSP files.

Warning Warning
Unused global symbol

Reports unused globally accessible public functions, variables, classes, and properties. The validation works in JavaScript, ActionScript, HTML and JSP files.

Warning Warning
Unused local symbol

Reports unused locally accessible parameters, local variables, functions, classes and private member declarations. The validation works in JavaScript, ActionScript, HTML and JSP files.

Warning Warning

Potentially undesirable code constructs

InspectionDescriptionDefault Severity
'break' statement

Reports break statements. break statements that end case blocks are not reported.

Disabled
'break' statement with label

Reports labelled break statements.

Disabled
'continue' statement

Reports continue statements.

Disabled
'continue' statement with label

Reports labelled continue statements.

Disabled
'debugger' statement

Reports debugger statements, used for interaction with Javascript debuggers. Such statements should probably not be found in production code.

Disabled
'void' expression

Reports void expressions. Since void behaves completely differently in JavaScript and Java, these expressions maybe confusing.

Disabled
'with' statement

Reports with statements. with statements result in potentially confusing implicit bindings, and may behave strangely in setting new variables.

Warning Warning
Anonymous function

Reports anonymous functions. An explicit name of a function expression may be helpful for debugging. Function expressions without names are not reported if they have a name property specified in the ECMAScript 6 standard. For example, var bar = function() {}; is not reported.

Disabled
Comma expression

Reports comma expressions. Comma expressions are often a sign of overly clever code, and may lead to subtle bugs. Comma expressions in the initializer or update section of a for loop are ignored by this inspection.

Warning Warning
Conditional expression

Reports ternary conditional expressions. Some coding standards prohibit such expressions, in favor of explicit if statements.

Disabled
Labeled statement

Reports labeled statements.

Disabled
Last modified: 08 March 2021