Skip to content

[java] New Java XPath functions#2917

Merged
adangel merged 13 commits into
pmd:pmd/7.0.xfrom
oowekyala:java-new-xpath-functions
Nov 25, 2020
Merged

[java] New Java XPath functions#2917
adangel merged 13 commits into
pmd:pmd/7.0.xfrom
oowekyala:java-new-xpath-functions

Conversation

@oowekyala

@oowekyala oowekyala commented Nov 13, 2020

Copy link
Copy Markdown
Member

Describe the PR

These are changes extracted from #2899 for ease of reference, namely:

  • small changes to pmd-core and pmd-lang-test
    • I just improved error reporting for XPath rules. Now a failure should give more info, also, all failures are reported as PmdXPathException, including failure in our custom functions (currently there's a mix of raw RuntimeException, IllegalArgumentException, IllegalStateException)
  • the changes to parts of pmd-java that are not rule specific, including

This should be merged before #2899, to reduce that PR's diff

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)

@oowekyala oowekyala added an:enhancement An improvement on existing features / rules in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution labels Nov 13, 2020
@oowekyala oowekyala added this to the 7.0.0 milestone Nov 13, 2020
@ghost

ghost commented Nov 15, 2020

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 20 new violations, 1 new errors and 0 new configuration errors,
removes 0 violations, 2 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 695 violations,
introduces 1265 new violations, 10 new errors and 0 new configuration errors,
removes 1059 violations, 16 errors and 2 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 20 new violations, 10 new errors and 0 new configuration errors,
removes 0 violations, 11 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 695 violations,
introduces 1258 new violations, 10 new errors and 0 new configuration errors,
removes 1059 violations, 16 errors and 2 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset introduces new violations, {:errors=>{:new=>10, :removed=>11}, :violations=>{:new=>20, :removed=>0, :changed=>0}, :configerrors=>{:new=>0, :removed=>0}} new errors and new configuration errors,
removes violations, errors and configuration errors.
Full report
Compared to master:
This changeset introduces new violations, {:errors=>{:new=>10, :removed=>16}, :violations=>{:new=>1258, :removed=>1059, :changed=>695}, :configerrors=>{:new=>0, :removed=>2}} new errors and new configuration errors,
removes violations, errors and configuration errors.
Full report

Generated by 🚫 Danger

@adangel adangel self-assigned this Nov 23, 2020
@adangel

adangel commented Nov 23, 2020

Copy link
Copy Markdown
Member

E, [2020-11-15T15:23:06.773764 #11856] ERROR -- : Running pmdtester failed: #<Slop::MissingArgument: missing argument for -b, --base-branch>

Maybe the regression tester is not working yet for PRs against pmd/7.0.x? I'm still working through mails...

@adangel adangel mentioned this pull request Nov 23, 2020
14 tasks
@adangel

adangel commented Nov 24, 2020

Copy link
Copy Markdown
Member

Ok, re-running the workflow is only useful for temporary failed builds. It will re-run the builds with exactly the same git ref/sha, see https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/re-running-a-workflow:

Re-running a workflow uses the same GITHUB_SHA (commit SHA) and GITHUB_REF (Git ref) of the original event that triggered the workflow run.

If the base branch of a PR as advanced, that's not taken into consideration. The only way to rebuild seems to be a real push to the PR branch. Then a new pull_request event is created with an update git ref/sha.

I've pushed another merge now, let's see, if the regression tester is running now correctly...

Btw: the github ref/sha in pull requests is always the test merge commit created automatically by github.

@adangel

adangel commented Nov 24, 2020

Copy link
Copy Markdown
Member

Isn't it fun? New error:

   Please update your dependency to directly use the correct version 'xml-apis:xml-apis:1.0.b2'.
  Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will be ignored.
  
  E, [2020-11-24T08:28:21.876609 #12106] ERROR -- : POM relocation to an other version number is not fully supported in Gradle : xml-apis:xml-apis:2.0.2 relocated to xml-apis:xml-apis:1.0.b2.
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  A problem occurred configuring root project 'spring'.
  > Could not resolve all files for configuration ':classpath'.
     > Could not resolve com.beust:jcommander:1.35.
       Required by:
           project : > org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16 > org.asciidoctor:asciidoctorj:1.5.6
        > Could not resolve com.beust:jcommander:1.35.
           > Could not get resource 'https://plugins.gradle.org/m2/com/beust/jcommander/1.35/jcommander-1.35.pom'.
              > Could not GET 'https://plugins.gradle.org/m2/com/beust/jcommander/1.35/jcommander-1.35.pom'.
                 > Read timed out

I'm wondering, why this didn't appear in other builds yet?
Looks like the same error in Azure clouds and incompatible TTL settings for pooled HTTP connections....

@adangel

adangel commented Nov 24, 2020

Copy link
Copy Markdown
Member

Rerun, now back at sourceforge failure:

  --2020-11-24 09:09:44--  https://master.dl.sourceforge.net/project/pmd/pmd-regression-tester/pmd_7.0.x-baseline.zip?viasf=1
  Resolving master.dl.sourceforge.net (master.dl.sourceforge.net)... 216.105.38.12
  Connecting to master.dl.sourceforge.net (master.dl.sourceforge.net)|216.105.38.12|:443... connected.
  HTTP request sent, awaiting response... 503 Service Unavailable
  2020-11-24 09:10:00 ERROR 503: Service Unavailable.

@oowekyala

Copy link
Copy Markdown
Member Author

https://github.com/pmd/pmd/pull/2917/checks?check_run_id=1453031344#step:6:43193

Running pmdtester failed: #<NoMethodError: undefined method `download_baseline' for #Danger::Dangerfile:0x00005586ba34e8d8>

Looks like it comes from this line (or L44). Are these calls really needed? It looks like the baseline would be downloaded within the Runner::run call anyway

@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.

Running pmdtester failed: #<NoMethodError: undefined method `download_baseline' for #Danger::Dangerfile:0x00005586ba34e8d8>

Looks like it comes from this line (or L44). Are these calls really needed? It looks like the baseline would be downloaded within the Runner::run call anyway

I've fixed that already, probably forgot to delete these lines when merging (ce99966)

I've pushed a small fixes commit to this PR, that should trigger the rebuild. The build of a PR happens always on a test merge commit that github automatically creates, so it should include the fix on pmd/7.0.x.

If then GH actions is happy and regression tester runs, I'll merge this PR.

* qname ::= java binary name
* }</pre>
*/
public static final class InvocationMatcher {

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.

It might be better, to have the class InvocationMatcher in a separate file instead in TypeTestUtil.... something we can consider later, though. It's new API, so we can still move it around.

@Override
protected Class<?> parseArgument(String constantArg) throws XPathException {
try {
return Class.forName("net.sourceforge.pmd.lang.java.ast.AST" + constantArg);

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.

This provides the "nodeIs" function for java. The issue #1787 describes this actually as a general, core function, available for all languages. I think, it would be not too hard to port this class + BaseRewrittenFunction to core. But IMHO we should wait with that for later.
Therefore I'll keep #1787 open, as it is only fixed for java.

@adangel adangel merged commit 915163d into pmd:pmd/7.0.x Nov 25, 2020
@adangel

adangel commented Nov 25, 2020

Copy link
Copy Markdown
Member

introduces 20 new violations
https://chunk.io/pmd/9325997603b34530a06bee6cd769917c/diff1/spring-framework/index.html

I wonder, where these come from. These are all comment rules, that have been updated with #2802 ...

@adangel

adangel commented Nov 25, 2020

Copy link
Copy Markdown
Member

introduces 20 new violations
https://chunk.io/pmd/9325997603b34530a06bee6cd769917c/diff1/spring-framework/index.html

I wonder, where these come from. These are all comment rules, that have been updated with #2802 ...

Ah... it's one specific file: ReactorNettyTcpStompClientTests.java - previously, we had a parser error (java.lang.IllegalStateException: Disambiguation pass should resolve everything except qualified ctor calls) which is now solved...

@oowekyala

Copy link
Copy Markdown
Member Author

Ah... it's one specific file: ReactorNettyTcpStompClientTests.java - previously, we had a parser error (java.lang.IllegalStateException: Disambiguation pass should resolve everything except qualified ctor calls) which is now solved...

I was thinking that we could add some detection of this into pmd/pmd-regression-tester. We already detect "changed" violations. There could be "lost" violations, those that were deleted because of an error, and "recovered" violations, those that appeared because some error disappeared

@oowekyala oowekyala deleted the java-new-xpath-functions branch November 25, 2020 16:08
oowekyala added a commit that referenced this pull request Nov 25, 2020
* Improve docs
* Add missing tests for XPath functions
* TypeIsFunction has been replaced with BaseContextNodeTestFun,
so this deletes the file

getCommentOn is still untested. I wonder whether we really need it,
also, it's inefficient and not specified at all (because it's unused).
@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

an:enhancement An improvement on existing features / rules 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