Inspectopedia 2025.2 Help

Private method only used from inner class

Reports private methods which are only called from an inner class of the class containing the method. Such methods can be safely moved into that inner class.

Example:

public class Outer { public static void main(String[] args) { new Inner().run(args[0]); } static class Inner { void run(String arg) { // Method isEmpty() is used from Inner class only // consider moving it to the Inner class if (!isEmpty(arg)) { System.out.println("Argument is supplied"); } } } private static boolean isEmpty(String s) { return s != null && s.trim().isEmpty(); } }

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.

MethodOnlyUsedFromInnerClass
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 | Abstraction issues

Use the first checkbox below to ignore private methods which are called from an anonymous or local class.

Use the third checkbox to only report static methods.

Inspection options

Here you can find the description of settings available for the Private method only used from inner class inspection, and the reference of their default values.

Ignore methods called from an anonymous or local class

Default value:

Not selected
Only report 'static' methods

Default value:

Not selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection MethodOnlyUsedFromInnerClass

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025