Inspectopedia 2025.2 Help

Pointless arithmetic expression

Reports pointless arithmetic expressions. Such expressions include adding or subtracting zero, multiplying by zero or one, and division by one.

Such expressions may be the result of automated refactorings and they are unlikely to be what the developer intended to do.

The quick-fix simplifies such expressions.

Example:

void f(int a) { int x = a - a; int y = a + 0; int res = x / x; }

After the quick-fix is applied:

void f(int a) { int x = 0; int y = a; int res = 1; }

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.

PointlessArithmeticExpression
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 | Numeric issues

Note that in rare cases, the suggested replacement might not be completely equivalent to the original code for all possible inputs. For example, the inspection suggests replacing x / x with 1. However, if x is zero, the original code throws ArithmeticException or results in NaN. Also, if x is NaN, then the result is also NaN. It's very unlikely that such behavior is intended.

Inspection options

Here you can find the description of settings available for the Pointless arithmetic expression inspection, and the reference of their default values.

Ignore named constants in determining pointless expressions

Default value:

Selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection PointlessArithmeticExpression

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025