更新时间:2022-12-25 09:21:23
我可以排除带有特定注释的方法的警告吗?
您可以使用一种特定的注释(@SuppressWarnings
)来抑制警告,但不能使用其他注释(例如 @MyEvent
)来达到这种效果..>
至少不是开箱即用的.如果你愿意做一些编程,你可以开发自己的自定义过滤器来满足你的需求.
Checkstyle warns when I have a public method without javadoc, which is nice! When I override a public method I don't get the warning because the javadoc is already available in the parent class for the method.
Now I have an other annotation for my method for example @MyEvent
. Now I do get the warning but don't want it because the annotation says enough. Can I exclude warnings for methods with a specific annotation?
There are some solutions that involve adding stuff to my code like @SuppressWarnings
or comments like // CHECKSTYLE.OFF
but this does not make my code nicer, i could instead just add the javadoc. So I'm looking for a configuration level solution.
Can I exclude warnings for methods with a specific annotation?
You can suppress warnings by using one specific annotation (@SuppressWarnings
), but other annotations can not be used to that effect (such as @MyEvent
).
At least not out of the box. If you are willing to do some programming, you can develop your own custom filter that does what you need.