Skip to content

[core] Make more rules be recognized as rulechain (saxon HE)#3207

Merged
adangel merged 1 commit into
pmd:pmd/7.0.xfrom
oowekyala:fix-java-rulechain
Apr 23, 2021
Merged

[core] Make more rules be recognized as rulechain (saxon HE)#3207
adangel merged 1 commit into
pmd:pmd/7.0.xfrom
oowekyala:fix-java-rulechain

Conversation

@oowekyala

@oowekyala oowekyala commented Apr 9, 2021

Copy link
Copy Markdown
Member

Describe the PR

I noticed many java XPath rules were not recognized as rulechain ones and investigated. Saxon parses some expressions somewhat inconsistently. Now we have a normalization step that should bring more rules in line with what the RuleChainAnalyser expects.

Java rules that were not recognized as Rulechain and that now are:

  • AvoidDecimalLiteralsInBigDecimalConstructor
  • AvoidPrintStackTrace
  • AvoidSynchronizedAtMethodLevel
  • AvoidUsingVolatile
  • DoNotUseThreads
  • DontCallThreadRun
  • EmptyMethodInAbstractClassShouldBeAbstract
  • JUnit4TestShouldUseTestAnnotation
  • LocalHomeNamingConvention
  • LocalInterfaceSessionNamingConvention
  • MDBAndSessionBeanNamingConvention
  • RemoteInterfaceNamingConvention
  • RemoteSessionInterfaceNamingConvention
  • ReplaceHashtableWithMap
  • ReplaceVectorWithList
  • SimplifyStartsWith
  • StringToString
  • UseAssertEqualsInsteadOfAssertTrue
  • UseAssertNullInsteadOfAssertTrue
  • UseAssertSameInsteadOfAssertTrue
  • UseAssertTrueInsteadOfAssertEquals
  • UseStringBufferLength

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

Now we have a normalization step that pulls up filters,
and reduces the start expression, so that the rulechain
analyser can recognise the pattern

Add tests for java rulechain

Rules that were not recognized as Rulechain and that now are:
- AvoidDecimalLiteralsInBigDecimalConstructor
- AvoidPrintStackTrace
- AvoidSynchronizedAtMethodLevel
- AvoidUsingVolatile
- DoNotUseThreads
- DontCallThreadRun
- EmptyMethodInAbstractClassShouldBeAbstract
- JUnit4TestShouldUseTestAnnotation
- LocalHomeNamingConvention
- LocalInterfaceSessionNamingConvention
- MDBAndSessionBeanNamingConvention
- RemoteInterfaceNamingConvention
- RemoteSessionInterfaceNamingConvention
- ReplaceHashtableWithMap
- ReplaceVectorWithList
- SimplifyStartsWith
- StringToString
- UseAssertEqualsInsteadOfAssertTrue
- UseAssertNullInsteadOfAssertTrue
- UseAssertSameInsteadOfAssertTrue
- UseAssertTrueInsteadOfAssertEquals
- UseStringBufferLength
@oowekyala oowekyala added the in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution label Apr 9, 2021
@oowekyala oowekyala added this to the 7.0.0 milestone Apr 9, 2021
Comment thread pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/XPathRuleTest.java Outdated
@oowekyala oowekyala force-pushed the fix-java-rulechain branch from ca2e632 to e2a4857 Compare April 9, 2021 23:08
@ghost

ghost commented Apr 9, 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 2916 violations,
introduces 8108 new violations, 1 new errors and 0 new configuration errors,
removes 15636 violations, 10 errors and 2 configuration errors.
Full report

Generated by 🚫 Danger

@oowekyala oowekyala changed the title [core] Fix bug with simple query parsed weirdly by saxon [core] Make more rules be recognized as rulechain (saxon HE) Apr 11, 2021
@oowekyala oowekyala marked this pull request as ready for review April 11, 2021 13:04
@adangel adangel added the for:performance The goal of this change is to improve PMD's performance label Apr 23, 2021
@adangel adangel mentioned this pull request Apr 23, 2021
14 tasks

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@adangel adangel self-assigned this Apr 23, 2021
@adangel adangel merged commit 4c9ee04 into pmd:pmd/7.0.x Apr 23, 2021
@oowekyala oowekyala deleted the fix-java-rulechain branch April 23, 2021 13:25
@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

for:performance The goal of this change is to improve PMD's performance in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants