[apex] Apex equivalent for Java's CommentRequiredRule #3038
-
Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex]. Affects PMD Version: - All Rule: - CommentRequiredRule Description: - As in PMD for java has a rule for CommentRequiredRule, is there a CommentRequiredRule rulecheck for PMD too ? Or do we have to write our own rulesets? I was going to extend the AbstractApexRule implement this but found out that Comment class is not present in Running PMD through: Maven |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
@Nagendra080389 welcomed. I fear I had some trouble understanding your issue, If I understand correctly you want an Apex rule that's equivalent to Java's If so, then no, there is no such rule, and there can't be at the time being. As recently explained on #1087, we use Apex Jorje to parse Apex source code, and that parser drops all comments, meaning they are not available for PMD analyze. I'm closing this as not implementable as it's not dependent on our own efforts. Feel free to reopen if I misunderstood you. |
Beta Was this translation helpful? Give feedback.
-
@jsotuyod Yep you understood correctly. Thanks. |
Beta Was this translation helpful? Give feedback.
-
No, without access to the comments in the AST this can't be implemented. |
Beta Was this translation helpful? Give feedback.
-
@Nagendra080389 thanks to the recent work on #1314 implementing this now would be possible. If you are still interested in contributing, please let me know and I'll help you work out the details. |
Beta Was this translation helpful? Give feedback.
-
Hi @jsotuyod Yes I would be interested in this. Please let me know what needs to be done here? Looking at the code it seems like the rule has been added now. |
Beta Was this translation helpful? Give feedback.
-
@Nagendra080389 a rule exists, but it's probably not as versatile / configurable as the Java one. If it suffices your needs, then it's all good and will be shipped in 6.8.0. If it doesn't you can help us expand on it. |
Beta Was this translation helpful? Give feedback.
-
Ok sure, will checkout the current one. If this does not help, then I will modify it and raise PR or discuss what can more be implemented. |
Beta Was this translation helpful? Give feedback.
@Nagendra080389 welcomed. I fear I had some trouble understanding your issue, If I understand correctly you want an Apex rule that's equivalent to Java's
CommentRequiredRule
, right?If so, then no, there is no such rule, and there can't be at the time being. As recently explained on #1087, we use Apex Jorje to parse Apex source code, and that parser drops all comments, meaning they are not available for PMD analyze.
I'm closing this as not implementable as it's not dependent on our own efforts. Feel free to reopen if I misunderstood you.