FindBugs is an extremely useful static analysis tool for Java code that will flag many subtle bugs and point out bad practice. However, when using FindBugs with Android projects, it will complain about the name of the auto-generated Android resource inner classes, which start with a lower-case letter, e.g. com.example.app.R$attr. Obviously, there is not much you can do to change the names, so these warnings are of little use.
By defining a filter for FindBugs, the warnings can be suppressed. Create an XML-file with the following content and include the file as a filter when running FindBugs.
<FindBugsFilter> <Match> <Class name="~.*\.R\$.*"/> <Bug pattern="NM_CLASS_NAMING_CONVENTION"/> </Match> </FindBugsFilter>
If you run FindBugs through the Eclipse plugin, open Eclipse Preferences, go to Java > FindBugs and select the “Filter Files” tab. Click “Add…” next to “Exclude filter files” and select the XML-file you created earlier.
If you run FindBugs from a command line, include the option “-exclude <file.xml>”, where “<file.xml>” is the path and name of the XML-file you created.
The FindBugs filter mechanism is very versatile. Have a look at chapter 8 of the FindBugs manual for more information.