Menu

question about some rule attributes

2018-09-06
2018-09-10
  • supermanheng21

    supermanheng21 - 2018-09-06

    is there any document to explain typeResolution, dfa and multifile? I am not sure what they are about. Thank you.

     

    Last edit: supermanheng21 2018-09-06
    • Juan Sotuyo

      Juan Sotuyo - 2018-09-07

      What are you looking for? How to use it in Java rules? How to build them
      for other languages?

      There is little documentation for these. Other than typeResolution, which
      is the most mature and all doc is focused on consuming type information.

      Multifile is even disabled at the moment, as it's incomplete / incompatible
      with other PMD features such as incremental analysis.

      On Thu, Sep 6, 2018 at 3:36 AM supermanheng21 supermanheng21@users.sourceforge.net wrote:

      is there any document to explain typeResolution, dfa and multifile? I am
      not sure they are about. Thank you.


      question about some rule attributes


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/pmd/discussion/188192/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       
      • supermanheng21

        supermanheng21 - 2018-09-10

        I am looking for how to use them, and in fact, I don't even konw what they are and why use them.

         
  • Andreas Dangel

    Andreas Dangel - 2018-09-10

    There is indeed very little documentation available.
    As for the attributes: dfa = data flow analysis. Currently used by only one rule: DataflowAnomalyAnalysis.
    multifile is - as Juan mentioned - is not implemented yet. The idea is, that PMD can take more than one file into account when analysis, thus having a cross-project view.
    typeresolution is for Java rules enabled by default. It allows you, to retrieve the concrete Java type on some nodes, e.g. to figure out the type of a variable, you can call the method getType() on any TypeNode:

    public Object visit(ASTVariableDeclaratorId node, Object data) {
        Class<?> type = node.getType();
        ...
    

    So, you could restrict the rule to only look for e.g. "java.lang.String" or any other specific type.

     
  • Andreas Dangel

    Andreas Dangel - 2018-09-10

    More info can be found here: https://pmd.github.io/pmd-6.7.0/pmd_userdocs_extending_writing_pmd_rules.html
    Especially the section about "I need some kind of Type Resolution for my rule!"

     
    • supermanheng21

      supermanheng21 - 2018-09-10

      Thank you for your detailed explanation.

       

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.