Back to Intellij Community

ExtractMethodRecommender

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

2025.3-rc-2676 B
Original Source

Suggests extracting fragments of code to a separate method to make code more clear. This inspection has a number of heuristics to select good candidates for extraction, including the following ones.

  • The extracted fragment has no non-local control flow
  • The extracted fragment has exactly one output variable
  • There are no similar uses of output variable inside the extracted fragment and outside it
  • The extracted fragment has only few input parameters (no more than three by default; configured with the inspection option)
  • The extracted fragment is not smaller than the configured length (500 characters by default) but no bigger than 60% of the containing method body