Skip to content

[apex] FieldDeclarationsShouldBeAtStart: False positive with properties #6349

@parsam97

Description

@parsam97

Affects PMD Version: 7.15.0

Rule: FieldDeclarationsShouldBeAtStart

Description: Apex property declarations using accessor syntax ({ get; set; }) are not recognized as field declarations by this rule.
As a result, subsequent field declarations are incorrectly reported as violating the rule, even though the property is a valid field declaration in Apex.

Code Sample demonstrating the issue:

public class MyClass {
    public String var1 { get; set; }
    public String var2;
}

Expected outcome:

PMD reports a violation at line 3, but that's wrong. That's a false positive. var1 is a valid field declaration despite using property accessor syntax.

Running PMD through: Apex PMD vscode extension

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions