由于测试代码的质量和重要程度均比较低,所以在使用findbugs时往往需要跳过它们,一般的web项目工程内常见的测试代码包括单元测试(XXXTest.java),main方法,示例(XXXSample.java),过滤这些代码的方法如下:

 

step1.编写filter文件

<FindBugsFilter>
    <Match>
      <Method name="main" />
    </Match>
    <Match>
       <Class name="~.*\.*Test" />
    </Match>
    <Match>
       <Class name="~.*\.*Test\$.*" />
    </Match>
     <Match>
       <Class name="~.*\.*Sample" />
    </Match>
    <Match>
       <Class name="~.*\.*Sample\$.*" />
    </Match>

</FindBugsFilter>

 

 

step2.在eclipse plugin里添加上文的filter文件


findbugs中过滤测试类代码

相关文章:

  • 2021-07-20
  • 2021-08-07
  • 2022-12-23
  • 2021-12-10
  • 2021-04-27
  • 2022-02-17
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-05-23
  • 2021-05-08
相关资源
相似解决方案