This is really considered a mistake:
However, it seems difficult to catch all the possible cases (quote from a newer error):
This is a bit complicated, because to determine if a type is a Enum, we need type resolution.
I was able to configure a rule to check if the type of variables are Enum. This only works if Enum types are on the โauxclasspathโ of pmd, so type resolution can find it.
Your isolation example still causes this false positive because PMD does not know what ProcessStatus is. I checked this with java.math.RoundingMode, which is always in the classpath and will be solved.
("Your example" refers to the ticket author, not the OP when the stack overflows)
Your case may work with PMD 5, the source you are associated with belongs to PMD 4.
Update: the current source contains an additional check for enumerations:
// skip, if it is an enum if (type0.getType() != null && type0.getType().equals(type1.getType()) && type0.getType().isEnum()) { return data; }
source share