Menu

#1511 [core] Inconsistent behavior of Rule.start/Rule.end

PMD-5.4.4
closed
None
PMD
3-Major
Bug
2017-01-22
2016-08-07
No

See also [#1506].

Looking at the code, there is a difference in when/how often start&end is called: MonoThreadProcessor
calls it for each file, while the MultiThreadProcessor calls it only once - and for a ruleset instance, that is
never used, as for the threads, new rule instances will be created.

Related

Issues: #1506

Discussion

  • Juan Sotuyo

    Juan Sotuyo - 2017-01-14
    • status: open --> in-progress
    • assigned_to: Juan Sotuyo
    • Milestone: New Tickets --> PMD-5.4.4
     
  • Andreas Dangel

    Andreas Dangel - 2017-01-22

    It will be: Once Per File.

    the method start() will be called once per file, right before it's analysis starts,
    so you can initialize properly your rule here. Once the rule have finished analyzing the
    file's source code, the method end() will be invoked and you can assert there if your
    rule has been violated or not.

    Sharing data for one rule between files must happen differently, as in multithreaded case, multiple instances of the rule will be running. So you'll need some kind of static/shared data, if you need to analyze more than one class...

     
  • Andreas Dangel

    Andreas Dangel - 2017-01-22
    • status: in-progress --> closed
     
  • Andreas Dangel

    Andreas Dangel - 2017-01-22

    Thanks for fixing!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.