@SuppressWarnings more than one rule not working

Morten Frank picture Morten Frank · Apr 4, 2014 · Viewed 8.7k times · Source

PMD and SonarQube a nice tools but I have problems trying to suppress PMD warnings.

We use Lombok a lot in our project, so many of the model classes have a: @SuppressWarnings("PMD.UnusedPrivateField") as an class-level annotations.

This works fine.

The problem is, that if I wan't to ignore one more rule, I would expect the following syntax: @SuppressWarnings(value = { "PMD.UnusedPrivateField", "PMD.SingularField" }) This looks like the correct syntax, also reading the implementation of the PMD annotation.

However, this seems not to works: None of the rules are now suppressed.

Answer

colbadhombre picture colbadhombre · Sep 16, 2014

I would have expected this format (without the "value ="):

@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})

Similar format is working for me in PMD 5.1.3 (although Eclipse complains about them not being supported).