Checkstyle - check only method in interface

ε祈祈猫儿з 提交于 2019-12-07 06:13:40

问题


Is it possible apply JavadocMethod checker only on methods in interface? (not in implementation classes)


回答1:


We had plan to implement it also, keep at eye on issue, not sure when we fix it, or welcome to provide patch we already have full infrastructure for development.




回答2:


If you are using Java 6, you can annotate the implementing method with @Override, which will tell the JavadocMethod checker not to require a Javadoc comment. Quoting the JavadocMethod docs:

Javadoc is not required on a method that is tagged with the @Override annotation.

The documentation continues stating that you need Java 6. In Java 5, you can still use {@inheritdoc}, which is better than nothing:

However under Java 5 it is not possible to mark a method required for an interface (this was corrected under Java 6). Hence Checkstyle supports using the convention of using a single {@inheritDoc} tag instead of all the other tags.

The built-in Eclipse code formatter can automatically add the @Override annotations for you, so this should be pretty much what you need.



来源:https://stackoverflow.com/questions/13271326/checkstyle-check-only-method-in-interface

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