【发布时间】:2014-10-16 06:34:22
【问题描述】:
是否可以为特定字段或行制作 Findbugs 停用注释,而不是停用对所有方法包含的字段的整个检查?
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value="BEAN_SUPER_CALL_ON_OBJECT",
justification = "I don't want to overwrite the method, but otherwise our equals check issues a warning")
@Override
public boolean equals(final Object obj) {
// this should not be ignored
super.test(obj);
// this should be ignored
return super.equals(obj);
}
这行不通:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value="BEAN_SUPER_CALL_ON_OBJECT")
return super.equals(obj);
这也行不通:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value="BEAN_SUPER_CALL_ON_OBJECT")
super.equals(obj);
这可行,但仍然会弹出警告:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value="BEAN_SUPER_CALL_ON_OBJECT")
boolean ret_val = super.equals(obj);
return ret_val;
【问题讨论】:
-
嗯,为什么你要这样覆盖那个方法?
-
这只是一个简化的例子,大多数普通屏幕都无法在屏幕上获取此方法的代码 xD 这个没有意义,但问题是一样的。
标签: java annotations findbugs