Query module UseBraces

name
Misleading indentation
description
If a control structure does not use braces, misleading indentation makes it difficult to see which statements are within its scope.
kind
problem
problem.severity
warning
precision
very-high
id
java/misleading-indentation
tags
maintainability correctness logic

Imports

java

Provides all default Java QL imports.

Predicates

abortsControlFlow

A statement that aborts the regular control-flow.

ifElseIf

An else-if construction.

nextInBlock

Two consecutive statements in a Block statement or SwitchStmt.

nonBlockParent

The Stmt.getParent() relation restricted to not pass through Blocks or SwitchStmts.

shouldOutdent

The statement body is an unbraced trailing body of a control structure and succ is the next statement in the surrounding Block (or SwitchStmt).

suspectIndentation

The statement body is an unbraced trailing body of a control structure and succ is the next statement in the surrounding Block (or SwitchStmt). The indentation of statement succ is suspect because it is indented the same way as body and thus visually suggests to be part of the same syntactic scope as body.

unbracedTrailingBody

A control structure for which the trailing body (the syntactically last part) is not a Block. This is either an IfStmt or a LoopStmt, but not a DoStmt, since do-while statements don’t have a trailing body.