Skip to content

With --auto-gen-config invalid rule references might be generated #124

Closed

Description

@adangel

See pmd/pmd#4971 for an example:

The changeset contains a change to file pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/AbstractNamingConventionRule.java, which is not a rule by itself but a base class.

The regression tester however generates a ruleset like that:

[ERROR] Error at target/reports/HEAD/checkstyle/config.xml:8:5
  6|     <rule ref="category/apex/design.xml/CognitiveComplexity"/>
  7|     <rule ref="category/apex/design.xml/CyclomaticComplexity"/>
  8|     <rule ref="category/java/codestyle.xml/AbstractNamingConvention"/>
         ^^^^^ Unable to find referenced rule AbstractNamingConvention; perhaps the rule name is misspelled?

  9|     <rule ref="category/java/codestyle.xml/FieldNamingConventions"/>
 10|     <rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
[ERROR] Cannot load ruleset target/reports/HEAD/checkstyle/config.xml: An XML validation error occurred

But a rule "AbstractNamingConvention" doesn't exist...

The result is, that PMD is not executed at all and the diff report shows, that all violations are missing.

Activity

  1. added
    bug
    on Apr 25, 2024
  2. adangel commented on Mar 22, 2025

    @adangel
    MemberAuthor

    Same happens for a change in AbstractCounterCheckRule in apex - the regression tester considers this a rule in the category "internal"...

    Refs pmd/pmd#5617

  3. added this to the next milestone on Sep 19, 2025
  4. added a commit that references this issue on Sep 19, 2025
    a7a756a
  5. UncleOwen commented on Sep 21, 2025

    @UncleOwen
    Member

    #141 was only a partial fix

  6. added a commit that references this issue on Oct 9, 2025
  7. adangel commented on Oct 9, 2025

    @adangel
    MemberAuthor

    #141 was only a partial fix

    #141 actually fixed this specific bug (no invalid rule references are generated anymore). However, it created a new bug, as now the --auto-gen-config feature doesn't work anymore for rules that start with the prefix "Abstract".
    I therefore consider this a different bug.

    In general, I'm not reopening a bug ticket after the product has been released - as the bug is mentioned in the release notes and in the milestone etc. Rather, I'd prefer to create a new bug ticket, if the bug is not fixed against expectations or if the fix created a regression.

    Closing this issue again.

  8. added a commit that references this issue on Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions