1

FindBugs 似乎只显示每种方法中特定错误的第一次出现。这发生在 Eclipse 以及 FindBugs 独立客户端中。
如何配置 FindBugs 以显示所有事件?

例子:

import javax.annotation.Nonnull;

public class Bar
{
    public void meth(@Nonnull final String pArg) {
        System.out.println(pArg);
    }

    public void foo() {
        String s = null;
        meth(s);      // <<== bug marker here (NP_NONNULL_PARAM_VIOLATION)
        meth(null);   // no bug marker here
        meth(s);      // and none here either  :-(
    }
}

我正在使用最新的 FindBugs 2.0.2 Eclipse 插件(带有 Eclipse 3.6)。

该问题似乎取决于错误模式。例如,我看到每个方法不止一次命中DLS_DEAD_LOCAL_STORE,但没有NP_NONNULL_PARAM_VIOLATION。后者如上图所示。

谢谢!

4

1 回答 1

2

Findbugs 似乎只检查这些代码行是否存在此特定错误,根据控制流分析实际上可以达到这些错误。使用您的 3 个方法调用,第一个会导致 NPE,因此永远不会达到第二个和第三个。

以前的版本也有类似的错误报告:http: //sourceforge.net/p/findbugs/bugs/980/

于 2013-02-24T05:43:53.953 回答