Back to Intellij Community

NestedMethodCall

java/java-impl/resources/inspectionDescriptions/NestedMethodCall.html

2025.3-rc-2610 B
Original Source

Reports method calls used as parameters to another method call.

The quick-fix introduces a variable to make the code simpler and easier to debug.

Example:

public int y() { return 1; }
  public int f(int x) { return 2 * x; }

  public void foo() {
      int x = f(y());
  }

After the quick-fix is applied:

public int y() { return 1; }
  public int f(int x) { return 2 * x; }

  public void foo() {
      int y = y();
      int x = f(y);
  }

Use the inspection options to toggle the reporting of:

  • method calls in field initializers
  • calls to static methods
  • calls to simple getters