After fixing a few checkstyle errors in a project, my checkstyle plugin threw an error stating that I had an unused import. I looked up the file and found the import there. The only place the imported class was mentioned was in a java-doc comment.
import MyException;
class Y {
/**
* @throws MyException
*/
public void X() throws Exception {
//Do something.
}
}
Indeed, the java-doc is incorrect with the actual code, but I don’t think that import should be necessary, right?
If you have cases where a type is needed in a javadoc comment but is not actually used in the code, simply use the full class name in the javadoc comment.
This will retain the IDE hovers and eliminate the checkstyle error.