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']
Comments
Post a Comment