Skip to content

[core] Support global rules that report at the end of analysis #3920

@oowekyala

Description

@oowekyala

Note I don't expect this idea to be implemented as is, but the use case is worth describing. See the "alternatives" section.

Is your feature request related to a problem? Please describe.
Some unseful rules could be written if we had infrastructure to report violations at the end of the analysis, giving the rule a global view on the analysed project.

In particular, CPD could be made a PMD rule (depends on #3919) using this infrastructure. Other copy-paste detection mechanisms could be written using this logic (eg tree-based copy detection).

Describe the solution you'd like
TBD, key concerns are

  • memory usage: global rules shouldn't keep direct references to AST nodes
  • rendering: renderers are all written with the assumption that once a file is closed, no more violations can be reported on it. This assumption is also baked into the new FileAnalysisListener API...

Describe alternatives you've considered
This might be unfeasible as-is given the difficulty about renderers stated above. Maybe we should instead support rules that work in 2 passes (indexing + actual analysis).

Additional context

See also #3355 for a rejected proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:RFCA drafted proposal on changes to PMD, up for feedback form the team and communityan:enhancementAn improvement on existing features / rules

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions