Reports classes, methods, or fields in the specified inspection scope that are not used or unreachable from entry points.

An entry point can be the main method, tests, classes mentioned outside the specified scope, classes accessible from module-info.java, and so on. You can also configure custom entry points by using name patterns or annotations.

Example:


  public class Department {
    private Organization myOrganization;
  }

In this example, Department explicitly references Organization but if Department class itself is unused, then inspection will report both classes.

The inspection also reports parameters that are not used by their methods and all method implementations and overriders, as well as local variables that are declared but not used.

Note: Some unused members may not be reported during in-editor code highlighting. For performance reasons, a non-private member is checked only when its name rarely occurs in the project. To see all results, run the inspection by selecting Code | Inspect Code or Code | Analyze Code | Run Inspection by Name from the main menu.

Use the visibility settings below to configure members to be reported. For example, configuring report private methods only means that public methods of private inner class will be reported but protected methods of top level class will be ignored.

Use the entry points tab to configure entry points to be considered during the inspection run.

You can add entry points manually when inspection results are ready.

If your code uses unsupported frameworks, there are several options:

This way the annotated code accessible by the framework internals will be treated as used.