How to avoid Eclipse importing a class when putting the class name in the comments, so that checkstyle does not complain later?

有些话、适合烂在心里 提交于 2019-12-03 10:09:39

People don't agree whether this is a bug or not. Javadoc needs the imports to create appropriate links. I'd say checkstyle should provide an option (and Eclipse maybe too) to change the warning.

There are two relevant bug reports:

Update: The mentioned bug has been fixed in checkstyle. You know have the option to configure the behavior.

If you use the fully-qualified class name in the JavaDoc, Eclipse will not add an import, e.g.

/**
 * This class is a {@link java.io.File} that blah blah blah
 */

The Checkstyle bug has been fixed now. In Checkstyle config, go Imports > Unused Imports > click Open > make sure processJavadoc is checked.

Now Checkstyle doesn't warn on this anymore.

In checkstyle.xml, change

<module name="UnusedImports"/>

to:

<module name="UnusedImports">
        <property name="processJavadoc" value="true"/>
</module>

This requires version 6.0 of Checkstyle.

Source: https://github.com/jboss/jboss-parent-pom/issues/23

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!