简体   繁体   中英

Suppress Spotbugs warnings globally

I have one warning from spotbugs. This is suppressed with @SuppressFBWarnings in all those files. I need to find a way to suppress this from one place so that I don't have to @SuppressFBWarnings in each file in that package.

You can use a filter file

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
  <Class name="my.package.*" />
</Match>
</FindBugsFilter>

This file can be given to spotbugs as command line argument -exclude , or if you are using an IDE it probably can be configured to be used somewhere.

This is especially useful when you want to exclude third-party code, or generated code, where you can't add the annotation to begin with. But it also helps separate the spotbugs configuration and the code.

Also note the name attribute can be a regular expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM