Reports cases where the minimum or the maximum of two numbers can be calculated by means of Math.max() or Math.min() instead of doing it manually.

Example:

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

After the fix is applied, the result will be like this:

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

Use the checkbox below to disable this inspection for double and float This might be useful because quick-fix may slightly break semantics for float/ double when handling NaN. Thought in most cases it will actually fix the subtle bug when users did not care about NaN.

New in 2019.2