java - Findbugs, PMD or Checkstyle rule to find access by a field -


i have class caches set of values internally. these values can updated periodically , cached contents updated appropriately. long users of class like:

... public void anymethod(anyparams) {     anyobject value = cacheclass.getvalue(anykey);     ... } 

then life fine "value" not maintained locally. if this:

public class myclass {     private anyobject value = cacheclass.getvalue(somekey);    ... } 

then if cached value updated usage of may not see new value.

we use findbugs, checkstyle , pmd in builds via sonar. wondering if there way define rule in of these systems detect , flag second type of usage above. have never written rule in these systems appreciate advice possible (like, "well can done, don't want go there..." :)

following xpath on ast node catch field declarations calls cacheclass method.

//fielddeclaration[//primaryexpression/primaryprefix/name/@image='cacheclass.getvalue'] 

how write pmd custom rule


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -