How find all unused classes in Intellij Idea?

Cherry picture Cherry · Mar 20, 2014 · Viewed 54.4k times · Source

There is an inspection "Unused declaration" which can find all unused code in Intellij Idea. (see this question) But I want to find all unused classes, not methods, variables etc. Only classes. (it is difficult to find only classes in 3000 result list). How I can do that?

Answer

BlondCode picture BlondCode · Jul 7, 2016
  • Press Ctrl+Shift+A (in Mac Command+Shift+A)
  • Enter "unused declar"
  • Double-click on "Unused declaration"

Settings will pop up

  • Click on Java/Declaration redundancy/Unused declaration
  • on the right bottom select "On the fly editor settings"
  • untick check fields, ..., check parameters. Only Check Classes should be ticked.
  • Press OK

Settings closes

  • On the menu bar, click on Analyze / Run Inspection by Name (or Ctrl+Alt+Shift+I - in Mac Command+Option+Shift+I)
  • Insert text "Unused decla"
  • Select "Unused declaration Java|Declaration redundancy"

Search starts

  • Check the job state on bottom of Idea, when finished: enjoy the results and the great feeling of cleaning up the messed code. :)