You've always been able to turn off PMD warnings with the "NOPMD" feature, for example:
But now there's a better way. If you want to turn off warnings for an entire class, you can use the Java standard annotation java.lang.SuppressWarnings
:
PMD will recognize that annotation and, well, suppress any warnings in that class. Much cleaner!
There's still more work to do, since the SuppressWarnings annotation can be also applied to fields, methods, constructors, parameters, and local variables. Also, it'd be nice to be able to only suppress warnings from specific rules. But anyhow, it's a good start.
Some notes I made while coding this up are here, and you can download an updated pmd-3.3.jar file here that includes this feature.
Thanks to Mark Levison for prodding me to get working on this feature!