Inspectopedia 2024.3 Help

Control flow issues

'break' statement  

Reports break statements that are used in places other than at the end of a switch statement branch.

'break' statement with label  

Reports break statements with labels.

'continue' statement  

Reports continue statements.

'continue' statement with label  

Reports continue statements with labels.

'default' not last case in 'switch'  

Reports switch statements or expressions in which the default branch is positioned before another case.

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

Reports for loops that contain neither initialization nor update components, and suggests converting them to while loops.

'for' loop with missing components   New in this release

Reports for loops that lack initialization, condition, or update clauses.

'if' statement with identical branches or common parts   New in this release

Reports if statements in which common parts can be extracted from the branches.

'if' statement with negated condition   New in this release

Reports if statements that contain else branches and whose conditions are negated.

'if' statement with too many branches  

Reports if statements with too many branches.

'switch' statement   New in this release

Reports switch statements.

'switch' statement with too low of a branch density   New in this release

Reports switch statements or expressions with a too low ratio of switch labels to executable statements.

'switch' statement without 'default' branch   New in this release

Reports switch statements that do not contain default labels.

'while' can be replaced with 'do while'   New in this release

Reports while loops that could be more effectively written as do-while loops.

Assertion can be replaced with 'if' statement   New in this release

Reports assert statements and suggests replacing them with if statements that throw java.lang.AssertionError.

Boolean expression can be replaced with conditional expression   New in this release

Reports any boolean expressions which can be formulated in a more compact and, arguably, clear way than by using a conditional expression.

Common subexpression can be extracted from 'switch'   New in this release

Reports switch expressions and statements where every branch has a common subexpression, and the switch can be moved inside.

Conditional break inside loop   New in this release

Reports conditional breaks at the beginning or at the end of a loop and suggests adding a loop condition instead to shorten the code.

Conditional can be pushed inside branch expression   New in this release

Reports conditional expressions with then and else branches that are similar enough so that the expression can be moved inside.

Conditional expression  

Reports usages of the ternary condition operator and suggests converting them to if/else statements.

Conditional expression with identical branches  

Reports conditional expressions with identical then and else branches.

Conditional expression with negated condition   New in this release

Reports conditional expressions whose conditions are negated.

Constant conditional expression  

Reports conditional expressions in which the condition is either a true or false constant.

Double negation   New in this release

Reports double negations that can be simplified.

Duplicate condition  

Reports duplicate conditions in && and || expressions and branches of if statements.

Enum 'switch' statement that misses case   New in this release

Reports switch statements over enumerated types that are not exhaustive.

Expression can be factorized   New in this release

Reports expressions that can be factorized, i.e.

Fallthrough in 'switch' statement  

Reports 'fall-through' in a switch statement.

Idempotent loop body   New in this release

Reports loops whose second and all subsequent iterations do not produce any additional side effects other than the one produced by the first iteration, which can indicate a programming error.

Infinite loop statement  

Reports for, while, or do statements that can only exit by throwing an exception.

Labeled statement  

Reports labeled statements that can complicate refactorings and control flow of the method.

Local variable used and declared in different 'switch' branches   New in this release

Reports local variables declared in one branch of a switch statement and used in another branch.

Loop statement that does not loop   New in this release

Reports any instance of for, while, and do statements whose bodies will be executed once at most.

Loop variable not updated inside loop   New in this release

Reports any variables and parameters that are used in a loop condition and are not updated inside the loop.

Loop with implicit termination condition   New in this release

Reports any while, do-while, and for loops that have the true constant as their only condition.

Maximum 'switch' branches   New in this release

Reports switch statements or expressions with too many case labels.

Minimum 'switch' branches   New in this release

Reports switch statements and expressions with too few case labels, and suggests rewriting them as if and else if statements.

Negated conditional expression  

Reports conditional expressions which are negated with a prefix expression, as such constructions may be confusing.

Negated equality expression   New in this release

Reports equality expressions which are negated by a prefix expression.

Nested 'switch' statement  

Reports nested switch statements or expressions.

Nested conditional expression  

Reports nested conditional expressions as they may result in extremely confusing code.

Overly complex boolean expression  

Reports boolean expressions with too many terms.

Pointless 'indexOf()' comparison   New in this release

Reports unnecessary comparisons with .indexOf() expressions.

Pointless boolean expression   New in this release

Reports unnecessary or overly complicated boolean expressions.

Redundant 'else'   New in this release

Reports redundant else keywords in if—else statements and statement chains.

Redundant 'if' statement  

Reports if statements that can be simplified to a single assignment, return, or assert statement.

Simplifiable boolean expression   New in this release

Reports boolean expressions that can be simplified.

Simplifiable conditional expression   New in this release

Reports conditional expressions and suggests simplifying them.

Statement can be replaced with 'assert' or 'Objects.requireNonNull'   New in this release

Reports if statements that throw only java.lang.Throwable from a then branch and do not have an else branch.

Unnecessary 'null' check before method call   New in this release

Reports null checks followed by a method call that will definitely return false when null is passed (e.g.

Last modified: 11 September 2024