Menu

check Custom rule for non-test classes/base class

2020-10-12
2020-10-23
  • Puneet Jain

    Puneet Jain - 2020-10-12

    Hi,
    I have to check any rule for non test class.
    Example - All SOQL statements in non-test classes should be either bound by a LIMIT clause or WHERE clause.
    How can we check for non-test classes only?

     
  • Andreas Dangel

    Andreas Dangel - 2020-10-23

    Please refer to https://pmd.github.io/latest/pmd_userdocs_extending_designer_reference.html This explains how to use the rule designer to see the data, that is available in the AST nodes.

    A XPath Query could look like this:

    //UserClass[not(ModifierNode/Annotation[@Image = 'IsTest'])]
      //SoqlExpression
        [not(contains(@CanonicalQuery, 'LIMIT'))]
        [not(contains(@CanonicalQuery, 'WHERE'))]
    

    Feel free to ask the question again on https://github.com/pmd/pmd/issues as github is the main place where contributors will see your question.

     

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.