Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apex] ExcessivePublicCount ignores properties #4596

Closed
jfeingold35 opened this issue Jun 14, 2023 · 1 comment · Fixed by #4604
Closed

[apex] ExcessivePublicCount ignores properties #4596

jfeingold35 opened this issue Jun 14, 2023 · 1 comment · Fixed by #4604
Assignees
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@jfeingold35
Copy link
Contributor

Affects PMD Version: 7.0.0-rc3

Rule:

Please provide the rule name and a link to the rule documentation:
ExcessivePublicCount

Description:
Unlike previous versions of the rule (e.g., 6.55.0), the 7.x version no longer includes getters/setters in its total.

Code Sample demonstrating the issue:

public class ClassDemonstratingIssue {
    public String prop1 {get; set;}
    public String prop2 {get; set;}
    public String prop3 {get; set;}
    public String prop4 {get; set;}
    public String prop5 {get; set;}
    public String prop6 {get; set;}
    public String prop7 {get; set;}
    public String prop8 {get; set;}
    public String prop9 {get; set;}
    public String prop10 {get; set;}
    public String prop11 {get; set;}
    public String prop12 {get; set;}
    public String prop13 {get; set;}
    public String prop14 {get; set;}
    public String prop15 {get; set;}
    public String prop16 {get; set;}
    public String prop17 {get; set;}
    public String prop18 {get; set;}
    public String prop19 {get; set;}
    public String prop20 {get; set;}
    public String prop21 {get; set;}
    public String prop22 {get; set;}
}

Expected outcome:

This class should violate ExcessivePublicCount, as it does in PMD 6.55.0.
Note that if you remove the {get; set;}, then it starts throwing violations again. It seems to just be when there's the getters/setters that the 7.x version of the rule returns false negatives.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
CLI

@jfeingold35 jfeingold35 added the a:false-negative PMD doesn't flag a problematic piece of code label Jun 14, 2023
@adangel adangel self-assigned this Jun 24, 2023
@adangel
Copy link
Member

adangel commented Jun 24, 2023

With PMD 7, the rule has been changed to consider only "top-level" methods of a class. This excluded methods defined inside a property. The properties' methods have only been considered accidentally in PMD 6.

However, these properties are still public members and should be considered towards the public count. I'm going to change the rule to count explicitly "properties" in addition to "methods" and "attributes" (aka. fields). However, I'm only counting each property once (PMD 6 counted each property twice, as it didn't count properties but methods).

@adangel adangel changed the title [apex] ExcessivePublicCount ignores getters/setters [apex] ExcessivePublicCount ignores properties Jun 24, 2023
@adangel adangel added this to the 7.0.0 milestone Jun 24, 2023
adangel added a commit to adangel/pmd that referenced this issue Jun 24, 2023
adangel added a commit to adangel/pmd that referenced this issue Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants