Skip to content

PMD rule sets can no longer contain apex rules #319

@ChrisGottlieb

Description

@ChrisGottlieb

Affected Version

2.1.0 on Intellij IDEA 2025.3.4

Description:

None of the apex related PMD rules work any longer. Referencing them in a rule set breaks the rule set.

Steps to replicate:

  1. Create a rule set xml containing:
<?xml version="1.0"?>
<ruleset name="Custom 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>
        My custom rules
    </description>
    <rule ref="category/apex/bestpractices.xml/AvoidGlobalModifier" />
</ruleset>
  1. Try to load it as a rule set under: Settings | Tools | PMD | RuleSets | +

Expected result:

The file should be accepted.

Actual result:

Error: "The selected file/URL is not valid for PMD 7. PMD: Cannot load ruleset category/apex/bestpractices.xml/AvoidGlobalModifier: Cannot resolve rule/ruleset reference 'category/apex/bestpractices.xml/AvoidGlobalModifier'. Make sure the resource is a valid file ..."

Further reference:

https://pmd.github.io/pmd/pmd_rules_apex_bestpractices.html#avoidglobalmodifier defines this rule and is currently supported.

Workaround:

Reverting the Plugin to Version 2.0.7. where the rules can still be referenced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions