Skip to content

[BUG][code-analyzer] Potential PMD Issue: exclude-pattern in Referenced Ruleset Not Respected #1820

@ssaini01

Description

@ssaini01

I'm encountering an issue with configuring code-analyzer to exclude files with specific prefixes. This is for a Salesforce org repository, and I'm using the PMD engine with a custom custom-ruleset.xml file. Despite specifying the prefixes to be ignored, the scanner still seems to process those files. For example I want to exclude Apex classes that have a prefix of fflib_ or TM. This is what the custom-ruleset.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom Apex Rules"
         xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
                             https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

  <description>
    PMD ruleset that excludes fflib-related and TM-prefixed classes and their metadata files.
  </description>

  <!-- Exclude patterns -->
  <exclude-pattern>.*/fflib_.*\.(cls|trigger|cls-meta\.xml|trigger-meta\.xml)$</exclude-pattern>
  <exclude-pattern>.*/fflib-.*/.*\.(cls|trigger|cls-meta\.xml|trigger-meta\.xml)$</exclude-pattern>
  <exclude-pattern>.*/TM[^/]*\.(cls|trigger|cls-meta\.xml|trigger-meta\.xml)$</exclude-pattern>

  <!-- Apex rules -->
  <rule ref="category/apex/design.xml/CognitiveComplexity"/>
  <rule ref="category/apex/bestpractices.xml/ApexUnitTestClassShouldHaveAsserts"/>
</ruleset>

Do you have any suggestions on what I might be missing? Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForFixFromPMDWaiting for PMD to fix an issue so that we can incorporate the fix into Salesforce Code Analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions