Inspectopedia Help

Unnecessary parentheses

Reports any instance of unnecessary parentheses.

Parentheses are considered unnecessary if the evaluation order of an expression remains unchanged after you remove the parentheses.

Example:

int n = 3 + (9 * 8);

After quick-fix is applied:

int n = 3 + 9 * 8;

Configure the inspection:

  • Use the Ignore clarifying parentheses option to ignore parentheses that help clarify a binary expression. Parentheses are clarifying if the parenthesized expression is an instanceof expression that is a part of a larger expression or has a different operator than the parent expression.

  • Use the Ignore parentheses around the condition of conditional expressions option to ignore any parentheses around the condition of conditional expressions. Some coding standards specify that all such conditions must be surrounded by parentheses.

  • Use the Ignore parentheses around single no formal type lambda parameter option to ignore parentheses around a single lambda parameter within a lambda expression.

Inspection options

Option

Type

Default

Ignore clarifying parentheses

Checkbox

false

Ignore parentheses around the condition of conditional expressions

Checkbox

false

Ignore parentheses around single no formal type lambda parameter

Checkbox

false

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023