Skip to content

[java] Update rule ComparisonWithNaN#3396

Merged
adangel merged 2 commits into
pmd:pmd/7.0.xfrom
oowekyala:update-ComparisonWithNaN
Jul 16, 2021
Merged

[java] Update rule ComparisonWithNaN#3396
adangel merged 2 commits into
pmd:pmd/7.0.xfrom
oowekyala:update-ComparisonWithNaN

Conversation

@oowekyala

Copy link
Copy Markdown
Member

@oowekyala oowekyala added this to the 7.0.0 milestone Jul 9, 2021
@ghost

ghost commented Jul 10, 2021

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 30191 violations,
introduces 32705 new violations, 3 new errors and 0 new configuration errors,
removes 143884 violations, 8 errors and 3 configuration errors.
Full report

Generated by 🚫 Danger

@adangel

adangel commented Jul 10, 2021

Copy link
Copy Markdown
Member

Not sure, whether this is related to your change, but regression tester ended finally with "Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "PmdThread 1""...

The log file (I recommend to download it and not look in the browser at the huge 237mb log...) show some exceptions:

2021-07-10T00:21:53.7990444Z WARNING: Exception applying rule CloseResource on file /home/runner/work/pmd/target/repositories/spring-framework/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java, continuing with next rule
2021-07-10T00:21:53.8630016Z Caused by: java.lang.NullPointerException
without stack trace, that means, NPE are very, very often....

...

2021-07-10T00:21:53.8652310Z WARNING: Exception applying rule DontImportSun on file /home/runner/work/pmd/target/repositories/spring-framework/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java, continuing with next rule
2021-07-10T00:21:53.9277683Z Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
2021-07-10T00:21:53.9279660Z    at net.sourceforge.pmd.lang.ast.impl.AbstractNode.getChild(AbstractNode.java:55)
2021-07-10T00:21:53.9282457Z    at net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule.visit(DontImportSunRule.java:14)
2021-07-10T00:21:53.9285802Z    at net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration.acceptVisitor(ASTImportDeclaration.java:115)

...

2021-07-10T00:21:53.7283233Z WARNING: Exception applying rule BeanMembersShouldSerialize on file /home/runner/work/pmd/target/repositories/spring-framework/spring-web/src/main/java/org/springframework/web/util/U
riComponentsBuilder.java, continuing with next rule
2021-07-10T00:21:53.7927144Z Caused by: java.lang.NullPointerException
2021-07-10T00:21:53.7929323Z    at net.sourceforge.pmd.lang.java.rule.AbstractLombokAwareRule.visit(AbstractLombokAwareRule.java:45)
2021-07-10T00:21:53.7932613Z    at net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration.acceptVisitor(ASTImportDeclaration.java:115)
2021-07-10T00:21:53.7935744Z    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor(AbstractJavaNode.java:50)
2021-07-10T00:21:53.7938636Z    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitor.visitNode(JavaParserVisitor.java:22)
2021-07-10T00:21:53.7941350Z    at net.sourceforge.pmd.lang.java.ast.JavaVisitor.visitJavaNode(JavaVisitor.java:6)
2021-07-10T00:21:53.7943623Z    at net.sourceforge.pmd.lang.java.ast.JavaVisitor.visit(JavaVisitor.java:7)
2021-07-10T00:21:53.7946220Z    at net.sourceforge.pmd.lang.java.rule.AbstractLombokAwareRule.visit(AbstractLombokAwareRule.java:40)
2021-07-10T00:21:53.7950220Z    at net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule.visit(BeanMembersShouldSerializeRule.java:56)

...

2021-07-10T00:21:53.6972556Z WARNING: Exception applying rule SuspiciousHashcodeMethodName on file /home/runner/work/pmd/target/repositories/spring-framework/spring-web/src/main/java/org/springframework/web/util
/UriComponents.java, continuing with next rule
2021-07-10T00:21:53.7201299Z Caused by: java.lang.NullPointerException
2021-07-10T00:21:53.7204100Z    at net.sourceforge.pmd.lang.java.rule.errorprone.SuspiciousHashcodeMethodNameRule.visit(SuspiciousHashcodeMethodNameRule.java:27)
2021-07-10T00:21:53.7208030Z    at net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration.acceptVisitor(ASTMethodDeclaration.java:51)
2021-07-10T00:21:53.7211049Z    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor(AbstractJavaNode.java:50)
2021-07-10T00:21:53.7213708Z    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitor.visitNode(JavaParserVisitor.java:22)
2021-07-10T00:21:53.7216355Z    at net.sourceforge.pmd.lang.java.ast.JavaVisitor.visitJavaNode(JavaVisitor.java:6)
2021-07-10T00:21:53.7218611Z    at net.sourceforge.pmd.lang.java.ast.JavaVisitor.visit(JavaVisitor.java:25)
2021-07-10T00:21:53.7221460Z    at net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBody.acceptVisitor(ASTClassOrInterfaceBody.java:26)

It seems to be only about these rules:

   4911 WARNING: Exception applying rule BeanMembersShouldSerialize
   1018 WARNING: Exception applying rule CloseResource
   4900 WARNING: Exception applying rule DontImportSun
      1 WARNING: Exception applying rule net.sourceforge.pmd.RuleSetTest$1
      1 WARNING: Exception applying rule net.sourceforge.pmd.RuleSetTest$4
      1 WARNING: Exception applying rule net.sourceforge.pmd.RuleSetTest$6
      1 WARNING: Exception applying rule net.sourceforge.pmd.SourceCodeProcessorTest$RuleThatThrows
      9 WARNING: Exception applying rule SingletonClassReturningNewInstance
   4605 WARNING: Exception applying rule SuspiciousHashcodeMethodName

(grep "WARNING: Exception applying rule " '1_build (ubuntu-latest).txt'| cut -c 30-|cut -d ' ' -f 1-5|sort|uniq -c)

BeanMembersShouldSerialize: not yet converted, but it is executed anyway for some reason....
CloseResource: not yet converted, but it is executed anyway for some reason...
DontImportSun: not yet converted - PR is available, so merging #3391 would probably make the errors for this rule go away.
SingletonClassReturningNewInstance: not yet converted, but it is executed anyway for some reason...
SuspiciousHashcodeMethodName: not yet converted - PR is available, so merging #3389 would probably make the errors for this rule go away.

Ok, so we execute all the rules, because ComparisonWithNaN is a XPath rule and now the whole errorprone category is executed... that's unfortunately currently how the regression tester works....

@oowekyala

Copy link
Copy Markdown
Member Author

that's unfortunately currently how the regression tester works....

We could disable the dynamic ruleset generation on the pmd 7 branch until all rules are ported:

pmd/Dangerfile

Line 16 in 58b8615

'--auto-gen-config',

@adangel adangel merged commit ac73f85 into pmd:pmd/7.0.x Jul 16, 2021
@oowekyala oowekyala deleted the update-ComparisonWithNaN branch July 16, 2021 10:06
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants