Inspectopedia 2024.3 Help

Method can be extracted

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

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.

ExtractMethodRecommender
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 | Code maturity

Inspection options

Here you can find the description of settings available for the Method can be extracted inspection, and the reference of their default values.

Minimum length of code to extract:|symbols

500

Maximum number of parameters

3

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.3, Qodana for JVM 2024.3,

Can be installed with plugin:

Java, 243.23126

Last modified: 03 December 2024