As part of our docs on rule writing, we have a section on multifile analysis: http://pmd.sourceforge.net/snapshot/pmd_userdocs_extending_writing_pmd_rules.html#i-want-to-implement-a-rule-that-analyze-more-than-the-class
The rule however, states things that are not quite true... The example, as it stands, will only work when running PMD single-threaded. If more than one thread is used, a separate RuleContext
is used per-thread, and the counters are separate (this could be fixed by using a static field for the counter instead of a rule context attribute). Moreover, the rule adds a violation upon calls to end
, which will be called once per analyzed-file, resetting the flag, which in turn means the counter didn't do what it was expected (counting all the expressions in all the source), but merely keeps counting per-file.
There is no way currently of actually knowing when analysis of all files finished to add such a violation. I'd strongly suggest getting rid of this section until we have a proper solution for multifile analysis.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4