1

We have a folder within our project that we would like to exclude from one PMD rule. For example, we want the rule FieldNamingConventions, but we just don't want it to run on a specific directory.

We've tried to something similar to the below to ignore all classes that contain Model:

<rule ref="category/apex/codestyle.xml/FieldNamingConventions">
 <properties>
      <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration['.*Model']"/>
    </properties>
</rule>

However PMD throws exceptions when it gets to that rule.

How can we go about getting this rule excluded just from this directory or files without having to suppress the rule in each single class?

1 Answer 1

0

I think you can have two ruleset files: one with all your rulesets but the one you want to ignore in the specific directory; the second one with the rule you want to ignore plus the the exclude pattern tag:

<exclude-pattern>.*/some/other/package/FunkyClassNamePrefix.*</exclude-pattern>

I tested this scenario on vscode, and it seems to work (two xml files). you can see more information here: https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .