When running through a pmd-generated xml report I noticed a UseSingleton violation where no class attribute was stored with the violation. There was a class file (as necessary with the report structure), but no class attribute, even if the class name was the same as that of the file.
Because of the way I process the xml, I need the class name, and not just the filename stored in the violation attributes. It would seem logical that particularly for the UseSingleton rule, the class name in violation of the rule would always be stored.
For the excessiveClassLength rule, it would be useful if the classname was mentioned in the text of the violation in question, also in the xml report.
Logged In: YES
user_id=1025393
Originator: YES
The same level of information is also missing in the UnusedImports violation in the xml report.
Essentially what I'm seeing now is:
<file name="xxx/xxx/xxx/yyy.java">
<violation line="72" rule="UseSingleton" ruleset="Design Rules" package="xxx.xxx.xxx" externalinfourl="http://pmd.sourceforge.net/rules/design.html#UseSingleton" priority="5">
All methods are static. Consider using Singleton instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
</violation>
</file>
======================================
I think for the violations in question the xml report should also include the class information, i.e.:
=======================================
<file name="xxx/xxx/xxx/yyy.java">
<violation line="72" rule="UseSingleton" ruleset="Design Rules" package="xxx.xxx.xxx" class="" externalinfourl="http://pmd.sourceforge.net/rules/design.html#UseSingleton" priority="5">
All methods in are static. Consider using Singleton instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
</violation>
</file>
OR
<file name="xxx/xxx/xxx/yyy.java">
<violation line="72" rule="UseSingleton" ruleset="Design Rules" package="xxx.xxx.xxx" externalinfourl="http://pmd.sourceforge.net/rules/design.html#UseSingleton" priority="5">
All methods in YYY are static. Consider using Singleton instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
</violation>
</file>
In both cases, the class info is either added as an attribute or the class name is specifically mentioned in the violation message. UseSingleton, ExcessiveClassLength, and UnusedImports should all adhere to adding this info.