Inspectopedia Help

Manual min/max calculation

Reports cases where the minimum or the maximum of two numbers can be calculated using a Math.max() or Math.min() call, instead of doing it manually.

Example:

public int min(int a, int b) { return b < a ? b : a; }

After the quick-fix is applied:

public int min(int a, int b) { return Math.min(a, b); }

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.

ManualMinMaxCalculation
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 | Verbose or redundant code constructs

Use the Disable for float and double option to disable this inspection for double and float types. This is useful because the quick-fix may slightly change the semantics for float/double types when handling NaN. Nevertheless, in most cases this will actually fix a subtle bug where NaN is not taken into account.

New in 2019.2

Inspection options

Here you can find the description of settings available for the Manual min/max calculation inspection, and the reference of their default values.

Disable for float and double

Not selected

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024