You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unhelpful parse exception message - just "Couldn't parse the source - there is not root node - Syntax Error??". Ideally, we would output here something like "at x:y, expect z, but found x". Note, that these two files explicitly contain syntax errors
➡️ Caused by the fact, that experimental parser doesn't generate a synthetic modifiers list node for enum values - and that's correct. Enum values can't have modifiers like "public", "static", or "final" - these are implicit.
Stacktrace 1
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
[1:Rule applied on node=ApexFile]
---------------------------------
at net.sourceforge.pmd.util.AssertionUtil.contexted(AssertionUtil.java:232)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:55)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:158)
at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.checkForNonExistentAnnotation(AvoidNonExistentAnnotationsRule.java:62)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:58)
at net.sourceforge.pmd.lang.apex.ast.ASTField.acceptApexVisitor(ASTField.java:42)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visit(ApexParserVisitor.java:24)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitApexNode(ApexParserVisitor.java:29)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:352)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:42)
at net.sourceforge.pmd.lang.apex.ast.ASTUserEnum.acceptApexVisitor(ASTUserEnum.java:18)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visit(ApexParserVisitor.java:24)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitApexNode(ApexParserVisitor.java:29)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:344)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:30)
at net.sourceforge.pmd.lang.apex.ast.ASTUserClass.acceptApexVisitor(ASTUserClass.java:21)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:20)
at net.sourceforge.pmd.lang.apex.ast.ASTApexFile.acceptApexVisitor(ASTApexFile.java:61)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.rule.AbstractApexRule.apply(AbstractApexRule.java:17)
at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:232)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:75)
... 9 more
Stacktrace 2
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
[1:Rule applied on node=ApexFile]
---------------------------------
at net.sourceforge.pmd.util.AssertionUtil.contexted(AssertionUtil.java:232)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:55)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:158)
at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.checkForNonExistentAnnotation(AvoidNonExistentAnnotationsRule.java:62)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:58)
at net.sourceforge.pmd.lang.apex.ast.ASTField.acceptApexVisitor(ASTField.java:42)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visit(ApexParserVisitor.java:24)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitApexNode(ApexParserVisitor.java:29)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:352)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:42)
at net.sourceforge.pmd.lang.apex.ast.ASTUserEnum.acceptApexVisitor(ASTUserEnum.java:18)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visit(ApexParserVisitor.java:24)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitApexNode(ApexParserVisitor.java:29)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:344)
at net.sourceforge.pmd.lang.apex.rule.errorprone.AvoidNonExistentAnnotationsRule.visit(AvoidNonExistentAnnotationsRule.java:30)
at net.sourceforge.pmd.lang.apex.ast.ASTUserClass.acceptApexVisitor(ASTUserClass.java:21)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor.visitNode(ApexParserVisitor.java:17)
at net.sourceforge.pmd.lang.apex.ast.ApexVisitor.visit(ApexVisitor.java:20)
at net.sourceforge.pmd.lang.apex.ast.ASTApexFile.acceptApexVisitor(ASTApexFile.java:61)
at net.sourceforge.pmd.lang.apex.ast.AbstractApexNode.acceptVisitor(AbstractApexNode.java:127)
at net.sourceforge.pmd.lang.apex.rule.AbstractApexRule.apply(AbstractApexRule.java:17)
at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:232)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:75)
... 9 more
Rule Changes
✅ EmptyStatementBlock - now finds empty catch blocks. Is this correct behavior or a false positive?
➡️ This is actually now correct behavior: Previously two AvoidDeeplyNestedIfStmts were reported on the same line, because the else-if block as incorrect line numbers in the jorje parser variant of PMD. The line numbers are now correct with the experimental parser.
➡️ Problem was, that methods defined in interfaces didn't have the implicit modifier attributes (public and abstract), so these methods weren't identified as public methods which need documentation. When determining the modifiers for a ASTMethod, now it is also checked whether this method is part of a interface, and if so, the modifiers are added.
✅ New ApexDoc violation - Missing ApexDoc @description - for static init block. Is this correct or is this a false positive?
➡️ The formal comments were not always added to the correct nodes. In this case, a formal comment on a field was added to the static block (which is in the AST actually the method <clinit>). In the Jorje variant, we didn't support formal comments for fields in AST, now we do. So, this is a overall improvement. Note: The rule ApexDoc doesn't consider fields.
✅ FieldDeclarationShouldBeAtStart is reporting wrong line number (it reports the initialization instead of the declaration)
➡️ The difference is, that now an additional space is added when there are multiple generic type params, e.g. instead of Map<Id,SObject> now it is Map<Id, SObject>. I like it this way better, so we keep it and expect slight changes in the violation messages.
Affects PMD Version:
Branch
experimental-apex-parserPart of #3766
Description:
Collection of parser bugs and rule differences, that need to be investigated.
Stacktrace 1
Stacktrace 2
<clinit>). In the Jorje variant, we didn't support formal comments for fields in AST, now we do. So, this is a overall improvement. Note: The rule ApexDoc doesn't consider fields.Map<Id,SObject>now it isMap<Id, SObject>. I like it this way better, so we keep it and expect slight changes in the violation messages.