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();
}
}
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
Option | Type | Default |
---|---|---|
Ignore methods called from an anonymous or local class | Checkbox | false |
Only report 'static' methods | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023