Search code examples
javaintellij-ideaentry-point

Why do I get Unused declaration on classes, methods and fields that I use?


I am fixing and cleaning up my school project and we are supposed to use the "InspectCode" feature in IntelliJ IDEA and to also fix all warnings before returning the project. I got some warnings under a category "Declaration redundancy/unused declaration/ Entry Points. I have no idea why. The description of "Unused declaration is:

"This inspection reports classes, methods or fields in the specified inspection scope that are not used or not reachable from entry points."

The classes, field and methods that IDEA are complaining about are all used/started etc. The project runs and averything works as it is supposed to.

public enum Direction {
/**
 * When the mob is set to move up.
 */
 UP_DIR,
 /**
 * When the mob is set to move down.
 */
DOWN_DIR,
/**
 * When the mob is set to move left.
 */LEFT_DIR,  /**
 * When the mob is set to move right.
 */RIGHT_DIR,  /**
 * When the mob is set to move upleft.
 */UPLEFT_DIR,  /**
 * When the mob is set to move upright.
 */UPRIGHT_DIR,  /**
 * When the mob is set to move downleft.
 */DOWNLEFT_DIR,  /**
 * When the mob is set to move downright.
 */DOWNRIGHT_DIR
}

Another error comes from this:

public static void main(String[] args) {
// Start the game
Game game = new Game();
game.start();
}

.

Is there a way to "fix" my code so I don't get these warnings?


Solution

  • Put the cursor at warning and press Alt+Enter enter image description here