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.
In my organization I use the PMD ignore option in POM file to suppress all warnings that are generated for client stubs (and kept in separate module) that we auto-generate, as those are third party client-stubs we don't tend to touch them thought there are any warnings or violations and I am assuming the same thing for ...
This implies that the compiler may show "unwanted" warnings, or filter out invocations that are in fact bugs. For the former case, @SuppressWarnings("unlikely-arg-type") will document the exception both for the user and for the compiler.
The @SuppressWarnings annotation disables certain compiler warnings. In this case, the warning about deprecated code ( "deprecation" ) and unused local variables or unused private methods ( "unused" ).
An unchecked warning tells a programmer that a cast may cause a program to throw an exception somewhere else. Suppressing the warning with @SuppressWarnings("unchecked") tells the compiler that the programmer believes the code to be safe and won't cause unexpected exceptions.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With