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] ApexDoc false-positive for the first method of an annotated Apex class #4774

Closed
liqingjun123 opened this issue Dec 15, 2023 · 6 comments
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@liqingjun123
Copy link

liqingjun123 commented Dec 15, 2023

Affects PMD Version: 7.0.0-rc4

Rule: ApexDoc

Description:

Code Sample demonstrating the issue:

/**
 * @description       : rest service
 **/
@RestResource(urlMapping='/api/v1/get/*') 
global without sharing class TestService {
    /**
     * @description Bar
     */
    public void bar() { return; }
}

Expected outcome:

PMD reports a violation at line 9, but that's wrong. That's a false positive.

"rest.cls","3","9","Missing ApexDoc comment","Documentation","ApexDoc"

Running PMD through: [CLI]

@liqingjun123 liqingjun123 added the a:false-positive PMD flags a piece of code that is not problematic label Dec 15, 2023
@liqingjun123 liqingjun123 changed the title PMD report ApexDoc issue for the first member of class with "RestResource" notation PMD incorrectly reports ApexDoc issue for the first member of class with "RestResource" notation Dec 15, 2023
@liqingjun123 liqingjun123 changed the title PMD incorrectly reports ApexDoc issue for the first member of class with "RestResource" notation PMD incorrectly reports ApexDoc issue for the first function of an Apex class with "RestResource" notation Dec 15, 2023
@liqingjun123
Copy link
Author

Hi Team, @clement.fournier@tu-dresden.de could you please help on the issue ASAP? Thanks very much

@jsotuyod
Copy link
Member

This is not a false positive. As per the rule's documentation, the rule will flag:

  • ApexDoc comments on void or constructor methods should not contain @return.

Your sample bar method's doc is effectively a violation.

@liqingjun123
Copy link
Author

liqingjun123 commented Dec 18, 2023

This is not a false positive. As per the rule's documentation, the rule will flag:

  • ApexDoc comments on void or constructor methods should not contain @return.

Your sample bar method's doc is effectively a violation.

@jsotuyod
I have updated the comments for the function bar method. Now the issue still exists as below.
"rest.cls","3","9","Missing ApexDoc comment","Documentation","ApexDoc"

@adangel adangel reopened this Dec 18, 2023
@adangel
Copy link
Member

adangel commented Dec 18, 2023

I can confirm: If the annotation @RestResource is removed, then the formal parameter of the method is present in the AST and the rule works. But if the annotation is added, then the formal parameter of the method is missing in the AST...

I guess, there is a bug when we map the comments to the (nearest) node.

@adangel adangel changed the title PMD incorrectly reports ApexDoc issue for the first function of an Apex class with "RestResource" notation [apex] ApexDoc false-positive for the firs tmethod of an Apex class annotated with "RestResource" Dec 18, 2023
@adangel adangel changed the title [apex] ApexDoc false-positive for the firs tmethod of an Apex class annotated with "RestResource" [apex] ApexDoc false-positive for the first method of an Apex class annotated with "RestResource" Dec 18, 2023
@liqingjun123
Copy link
Author

@adangel The issue blocks my project to use 7.0+.

@adangel adangel changed the title [apex] ApexDoc false-positive for the first method of an Apex class annotated with "RestResource" [apex] ApexDoc false-positive for the first method of an annotated Apex class Mar 1, 2024
@adangel adangel added this to the 7.0.0 milestone Mar 1, 2024
@adangel
Copy link
Member

adangel commented Mar 1, 2024

Thanks for the reminder. I've just verified, that this is actually already fixed in the current master branch, probably with the switch from Jorje to apex-parser (#3766).

@adangel adangel closed this as completed in a96b601 Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

No branches or pull requests

3 participants