These code quality metrics proviced by PMD and Eclipse are quite nice, it points out all sort of strange things. But there are some thing it doesn't get...
For example I came across a class written by another developer (not sure who at this point). The first thing that caught my attention about that class is the incessent use of this. to refer to local fields. And he would never use a class name to refer to another static field, which is what tripped eclipse to check. After reviewing the class and parent class in question I came across a doozie... all of the methonds and fields were static, except that the fields were initilized by a non-static constructor! It's not like it's a forced option, since you can use static { ... } to initilize static fields. There are just some stupid patterns that you can never imagine until you see them.
PMD definatly needs a "StaticFieldReference" rule, perhaps they also need a "StaticInitInConstructor" rule, where it barks if you set the value of a static field in the same class inside the constructor of a class. Manipulation is ok. |