Skip to content

Issue #12542: new TreeWalker property to skip java parsing exceptions#15204

Merged
nrmancuso merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:treewalker-property
Jul 12, 2024
Merged

Issue #12542: new TreeWalker property to skip java parsing exceptions#15204
nrmancuso merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:treewalker-property

Conversation

@mahfouz72

@mahfouz72 mahfouz72 commented Jul 6, 2024

Copy link
Copy Markdown
Member

@mahfouz72 mahfouz72 changed the title Issue #12542: new TreeWlaker property to skip java parsing exceptions Issue #12542: new TreeWalker property to skip java parsing exceptions Jul 6, 2024
@mahfouz72 mahfouz72 force-pushed the treewalker-property branch from d0da0a3 to fd95f44 Compare July 6, 2024 01:11
Comment thread src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
@mahfouz72 mahfouz72 force-pushed the treewalker-property branch from fd95f44 to 67a474a Compare July 6, 2024 01:25
@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate report

@github-actions

github-actions Bot commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/9815449674

Comment thread src/xdocs/config.xml Outdated
Comment thread src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java Outdated
@mahfouz72

Copy link
Copy Markdown
Member Author

There is an issue with circleci failures is unrelated

@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate report

@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate site

@github-actions

github-actions Bot commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate report

@github-actions

github-actions Bot commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate report

@github-actions

github-actions Bot commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

@mahfouz72

mahfouz72 commented Jul 6, 2024

Copy link
Copy Markdown
Member Author

Site:
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a12016_2024131549/index.html

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a12016_2024131549/config.html#TreeWalker_Properties


Reports:

  1. property is off: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a12016_2024133119/reports/diff/index.html
    • Parse exceptions are still thrown but the difference in line numbers only (expected)
  2. property is on with default severity (error) : https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a12016_2024140116/reports/diff/index.html
    • exceptions removed and treewalker violations with ex message are added instead (expected)
  3. property is on with severity ignore: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a12016_2024142818/reports/diff/index.html
    • exceptions removed with no violation message printed (expected)

@mahfouz72

Copy link
Copy Markdown
Member Author

github, generate report

@github-actions

github-actions Bot commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/9820066275

@mahfouz72

mahfouz72 commented Jul 6, 2024

Copy link
Copy Markdown
Member Author

I was trying to generate the report with HOE as true but the report generation failed

Error: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project sample: Error during page generation: Error rendering Maven report: Failed during checkstyle configuration: Exception was thrown while processing /home/runner/work/checkstyle/checkstyle/.ci-temp/contribution/checkstyle-tester/src/main/java/openjdk21/test/langtools/tools/javac/rawDiags/Error.java: IllegalStateException occurred while parsing file /home/runner/work/checkstyle/checkstyle/.ci-temp/contribution/checkstyle-tester/src/main/java/openjdk21/test/langtools/tools/javac/rawDiags/Error.java. 10:0: no viable alternative at input 'voiderror': NoViableAltException -> [Help 1]

So I think there is no way to test HOE true with regression because it will halt will generating the report?

@rnveach

rnveach commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

there is no way to test HOE true with regression because it will halt will generating the report

Yes, this property was basically created for regression, so it should not be modified.
https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/my_check.xml#L12-L13

@rnveach

rnveach commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

@rnveach

rnveach commented Jul 6, 2024

Copy link
Copy Markdown
Contributor

Regression provided looks good to me.

@mahfouz72

Copy link
Copy Markdown
Member Author

Why did we limit this to one project?

I thought that one project for this kind of updates is enough. I chose jdk21 as it has all forms of non-compilable Java code legacy syntax and new syntax.
do we actually need all projects here?

@mahfouz72 mahfouz72 force-pushed the treewalker-property branch from 8a12016 to be5710d Compare July 7, 2024 13:39
Comment thread src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java Outdated
}

/**
* {@inheritDoc} Processes the file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is more needed than the inherited doc ? I don't see us needing the sentence.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

there was a tool complained about {@inheritDoc} only. I don't remember what was it I think inspection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

https://circleci-tasks-prod.s3.us-east-1.amazonaws.com/storage/artifacts/2233fdd7-79cb-481c-a64c-0df373c0d898/239380ca-0213-4293-a3de-7b3eb22ce630/0/home/circleci/project/target/inspection-results/UnnecessaryInheritDoc.xml?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQVFQINEOHILZ4HBZ%2F20240709%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240709T190014Z&X-Amz-Expires=60&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGsaCXVzLWVhc3QtMSJHMEUCIGuos9ECRyKz%2FEI2eNcxiS98o1IFtAK8h3Xm14%2BigOm%2FAiEAliysTESi6If2MS6%2BAUsesdx4brtggV466%2FgZXWy5yRYqqwIINBADGgwwNDU0NjY4MDY1NTYiDGP5fXW0FaUNa2yHwiqIAsfVLtQ53oLNZVj1yNciONwk6b82LnyXosvv%2Bku%2BF6IMyXm1LlaOK7s9GqoCKABVWvFEjEGdpTY%2Buom2Bh7TpZ4s7f04Ji24UxVYn12h2CG4TDMjxuBFWtfgZcpznK5V6A5YgdyVKJyrhiQqnfCcYsuu7KULsbA7p1CpbfLe7q53EHYwivqdE%2FDZaC0AwK4BXDhBflCi2ZvAmvy51fmR%2FHUnATY8bJSdHskcDrlpOy7kr1hKZigUvZhn%2ByTYnbWMh%2BPYdUuroycI8IaIZE9FgTjhQtPfr9ndaqwqifv2R8RKLhpJpGz5SIRHAYipyw3OqFbyDwk1Ad4MZAlY%2FRz%2FqxIGgbTBxK8j6jChjLa0BjqdAcqC1Sx2d%2FQ4k3kujP5K7X%2FePtqFOISS642J1JHEkgzwNfDjh8rz1kCTvXvZ7vCK3yTgNhX7PM5yiJf%2FPV0O9oaZP9oabfT%2FpZnPd6G%2FZcZvaKNQMPlZ4LcPuDerYBKVWF6V4LWx5A%2FCQeWAg7DACwXpgo4pqdxo2nbUHupq%2BpKHetce9RLuqdzAouXxDI8wcw9N9R0jfyfkPsEIxuY%3D&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=0aa4e1223c40b2506e8de05e06307a0f1f6c21f0ce29ea6f66157e807413e004

This seems like a false violation since we added the suppressions. I don't know the intellij enough to know if we can suppress this without a javadoc. Please restore the sentence.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

restored

@rnveach

rnveach commented Jul 9, 2024

Copy link
Copy Markdown
Contributor

I am good with regression.

@mahfouz72 mahfouz72 force-pushed the treewalker-property branch 2 times, most recently from 2beb9f0 to d7f01d4 Compare July 9, 2024 19:08

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let’s do this

Comment thread src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
Please recheck that class name is specified as canonical name or read how to configure \
short name usage https://checkstyle.org/config.html\#Packages. Please also \
recheck that provided ClassLoader to Checker is configured correctly.
parse.exception=TreeWalker is skipped due to a parse exception - {0}

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.

User set skipFileOnJavaParseException but we tell him about Treewalker.
Something is mismatching.

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.

We need something like:
Java specific module are skipped due to parse exception

In this case user clearly match what he activated with new behavior

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@mahfouz72 mahfouz72 force-pushed the treewalker-property branch from d7f01d4 to 7f252e6 Compare July 12, 2024 11:49

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

Ok to merge.

@nrmancuso , please review message in case it should be improved

@romani romani assigned nrmancuso and unassigned romani Jul 12, 2024

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here’s my recommendation:

Please recheck that class name is specified as canonical name or read how to configure \
short name usage https://checkstyle.org/config.html\#Packages. Please also \
recheck that provided ClassLoader to Checker is configured correctly.
parse.exception=Java specific modules are skipped due to a parse exception - {0}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
parse.exception=Java specific modules are skipped due to a parse exception - {0}
parse.exception= Java specific (TreeWalker-based) modules are skipped due to an exception during parsing - {0}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should keep some tie to TreeWalker in the message to make it clear that it happened in some child of TreeWalker. Also, I would prefer “during parsing” since this could also be an exception thrown in the JavaAstVisitor, right?

@mahfouz72 mahfouz72 Jul 12, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we don't add a space after = for .properties file I think we should leave it as it is for consistency

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.

Extra space was typo

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.

I am good.
I just need keep few words: Java, Parse, Exception . To let users easily match it to skipFileOnJavaParseException

@mahfouz72 mahfouz72 force-pushed the treewalker-property branch 2 times, most recently from eb6b022 to 781b0b1 Compare July 12, 2024 16:26
@mahfouz72

mahfouz72 commented Jul 12, 2024

Copy link
Copy Markdown
Member Author

inspections failure

can you help me with this I don't understand this failure it didn't happen before

https://www.jetbrains.com/help/inspectopedia/InconsistentResourceBundle.html looks like a false positive

@mahfouz72 mahfouz72 force-pushed the treewalker-property branch from 781b0b1 to 84c2f2d Compare July 12, 2024 17:54

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome

@nrmancuso nrmancuso merged commit c323fe0 into checkstyle:master Jul 12, 2024
@mahfouz72 mahfouz72 deleted the treewalker-property branch May 9, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

new Treewalker property to skip all nested Modules if there is parsing exception

4 participants