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;

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

UnnecessaryParentheses
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Code style issues

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

Here you can find the description of settings available for the Unnecessary parentheses inspection, and the reference of their default values.

Ignore clarifying parentheses

Not selected

Ignore parentheses around the condition of conditional expressions

Not selected

Ignore parentheses around single no formal type lambda parameter

Not selected

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Can be installed with plugin:

Java, 242.22892

Last modified: 11 September 2024