简体   繁体   中英

FindBugs filters: regex doesn't work in Class element

I'm trying to configure FindBugs to ignore missing equals methods for data object classes (name ends with DO suffix). The documentation says that this should work:

  <Match>
    <Class name=".*DO" />
    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
  </Match>

However it doesn't and I'm starting to doubt that regex is supported for Class/@name. Interesting thing is that this actually works:

  <Match classregex=".*DO">
    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
  </Match>

PS: I'm using FindBugs 2.0.1

You need to add a tilde before regexs in FindBugs. So it should look more like this:

 <Match>
    <Class name="~.*DO" />
    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
 </Match>

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