Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #13934: Version updated from 3.2 to 3.4 #13945

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Issue #13934: Version updated from 3.2 to 3.4 #13945

merged 1 commit into from
Nov 13, 2023

Conversation

Rohanraj123
Copy link
Contributor

related #13934

@Rohanraj123
Copy link
Contributor Author

@romani Sir can you please review the changes and please provide me some enhancements if required.

@rnveach
Copy link
Member

rnveach commented Oct 25, 2023

@Rohanraj123 You have not resolved all my review items yet.

@romani
Copy link
Member

romani commented Oct 25, 2023

@Rohanraj123 , please redirect all questions to @rnveach , he is first reviewer for this PR.

@Rohanraj123
Copy link
Contributor Author

@Rohanraj123 You have not resolved all my review items yet.

@rnveach Sir, can you please one more time define the doables so that i can keep them in mind while making the changes. Would be helpful for my learning as well.

@rnveach
Copy link
Member

rnveach commented Oct 26, 2023

@Rohanraj123 Where is the confusion with the information you were given at #13934 (comment) and my review items at #13945 (comment) , #13945 (comment) , and #13945 (comment) .

@rnveach
Copy link
Member

rnveach commented Oct 26, 2023

@Rohanraj123
The line at

else if (SUPER_CLASS_PROPERTIES_JAVADOCS.containsKey(propertyName)
needs to be removed.

With it gone, it will re-generate the XML files with the correct versions. I recommend to start with a clean master first.

@Rohanraj123
Copy link
Contributor Author

@Rohanraj123 The line at

else if (SUPER_CLASS_PROPERTIES_JAVADOCS.containsKey(propertyName)

needs to be removed.
With it gone, it will re-generate the XML files with the correct versions. I recommend to start with a clean master first.

Sure sir Let me do the changes

@Rohanraj123
Copy link
Contributor Author

Rohanraj123 commented Oct 28, 2023

@rnveach Sir, removing the line of code you were reffering giving error : ```

[ERROR] com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest -- Time elapsed: 2.495 s <<< ERROR!
java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailNode.getChildren()" because "node" is null

@rnveach
Copy link
Member

rnveach commented Oct 28, 2023

Update the PR. I would need to see what is being done and the full stack trace.

@rnveach
Copy link
Member

rnveach commented Oct 30, 2023

@Rohanraj123 The exception being generated does not provide us information besides its failing to read a since version in a file. We need more information. I recommend start debugging and see why it is failing.

Add a second commit titled something like minor: add file name to xdoc generator exception.

Add the following to the commit:

diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java
index fdfeadb..6ae2ff8 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java
@@ -67,6 +67,12 @@
                     String.valueOf(StandardCharsets.UTF_8))) {
                 parser.parse(reader, sink);
             }
+            // -@cs[IllegalCatch] There is no other way to deliver filename that was under
+            // processing.
+            catch (Exception ex) {
+                throw new IllegalStateException("Exception was thrown while processing "
+                        + inputFile.getPath(), ex);
+            }
             finally {
                 sink.close();
             }

This will ensure we see the file causing the issue. I picked this spot from looking at the stack trace.

In addition, fix up your first commit to remove the unnecessary changes. Keep as clean as you can (meaning similar to the original code).

@Rohanraj123
Copy link
Contributor Author

Rohanraj123 commented Oct 31, 2023

Okay sir let me do the changes

@Rohanraj123
Copy link
Contributor Author

@rnveach Sir, I have added the catch check in XdocGenerator file. And squash them in one commit. When i tried to run mvn clean verify , It says that Exception arrives in src\xdocs\checks\whitespace\filetabcharacter.xml.template .
Sir it might take some time for me to work on this issue because my university exams are going on. So Please try to provide me some time.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Ok to merge

@romani romani assigned rnveach and unassigned romani Nov 3, 2023
@rnveach
Copy link
Member

rnveach commented Nov 3, 2023

@Rohanraj123 No worries. You have some time. I am looking into the issue a bit more to understand things.

@romani CI is failing, so is too soon to say it is ready for merging.

@rnveach
Copy link
Member

rnveach commented Nov 3, 2023

I was digging through the error and I think I understand the logic of why the code we removed is there. filetabcharacter is an FileSetCheck. The error for the since version is because it is looking for the javadoc of fileExtensions and not finding it since it is in the parent class and has no version number defined there. This is a property for all FileSetCheck, so I assume the reasoning for the removed code was that this class has been here long enough that all modules that use it, should have had it from the start. However, this logic starts to fall apart if we add a new property in the future to any abstract checks that are already in existence.

We can actually see this for 2 of the overrides we did for SINCE_VERSION_FOR_INHERITED_PROPERTY for 2 same inherited properties:

Map.entry("MissingDeprecatedCheck.violateExecutionOnNonTightHtml", "8.24"),
Map.entry("NonEmptyAtclauseDescriptionCheck.violateExecutionOnNonTightHtml", "8.3"),

And I think that's where the solution lies, we need to add these properties to this global override field. So I would expect us to add a few <ModuleName>.fileExtensions to the list with each module's specific version that it defines. Most likely all may be the same as Module's own version number.

Ideally, we could remove the need for this list if we did version comparing between the version the module was introduced versus the version the inherited property was introduced and taking the newest of the 2. We are tracking inherited properties directly through SUPER_CLASS_PROPERTIES_JAVADOCS. I would expect this to be done in another PR. @romani If you agree we should create the issue for this.

Edit: We would still need the override to fall back on if we changed extension of the module after it was introduced, like changing AbstractCheck to AbstractJavadocCheck. We have a few modules we are looking to do that to still. Only way to avoid the override is if we put a since version on the class hierarchy.

@romani
Copy link
Member

romani commented Nov 8, 2023

@Rohanraj123, if you think that this PR becomes a bit complicated to finish.
It is completely fine to pause it or abandon it and switch to easier issues to get experience a bit more before handling complicated.
We want you to be productive and not be burned by heavy problems. Sorry that we didn't predict that it is not easy issue.

@Rohanraj123
Copy link
Contributor Author

Rohanraj123 commented Nov 10, 2023

Sure @rnveach Sir , letme add .fileextensions first. Then we will discuss furthur

@romani
Copy link
Member

romani commented Nov 11, 2023

ci failure:

[INFO] Running com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.296 s <<< FAILURE! -- in com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest
[ERROR] com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest -- Time elapsed: 2.296 s <<< ERROR!
java.lang.IllegalStateException: Exception was thrown while processing src/xdocs/checks/whitespace/typecastparenpad.xml.template
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
 ....
  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.lang.NullPointerException
  at com.puppycrawl.tools.checkstyle.utils.JavadocUtil.getFirstChild(JavadocUtil.java:220)
  at com.puppycrawl.tools.checkstyle.utils.JavadocUtil.findFirstToken(JavadocUtil.java:200)
  at com.puppycrawl.tools.checkstyle.site.SiteUtil.getSinceVersionFromJavadoc(SiteUtil.java:727)
  at com.puppycrawl.tools.checkstyle.site.SiteUtil.getSinceVersion(SiteUtil.java:707)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertySinceVersionCell(PropertiesMacro.java:492)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertyRow(PropertiesMacro.java:233)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writeTablePropertiesRows(PropertiesMacro.java:187)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertiesTable(PropertiesMacro.java:130)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.execute(PropertiesMacro.java:102)
  at org.apache.maven.doxia.parser.AbstractParser.executeMacro(AbstractParser.java:145)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.processMacroEnd(XdocsTemplateParser.java:187)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.handleEndTag(XdocsTemplateParser.java:116)
  at org.apache.maven.doxia.parser.AbstractXmlParser.parseXml(AbstractXmlParser.java:238)
  at org.apache.maven.doxia.parser.AbstractXmlParser.parse(AbstractXmlParser.java:156)
  at org.apache.maven.doxia.parser.XhtmlBaseParser.parse(XhtmlBaseParser.java:92)
  at org.apache.maven.doxia.module.xdoc.XdocParser.parse(XdocParser.java:113)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.parse(XdocsTemplateParser.java:76)
  at org.apache.maven.doxia.parser.AbstractParser.parse(AbstractParser.java:207)
  at com.puppycrawl.tools.checkstyle.internal.utils.XdocGenerator.generateXdocContent(XdocGenerator.java:68)
  ... 62 more

@Rohanraj123
Copy link
Contributor Author

ci failure:

[INFO] Running com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.296 s <<< FAILURE! -- in com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest
[ERROR] com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest -- Time elapsed: 2.296 s <<< ERROR!
java.lang.IllegalStateException: Exception was thrown while processing src/xdocs/checks/whitespace/typecastparenpad.xml.template
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
 ....
  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.lang.NullPointerException
  at com.puppycrawl.tools.checkstyle.utils.JavadocUtil.getFirstChild(JavadocUtil.java:220)
  at com.puppycrawl.tools.checkstyle.utils.JavadocUtil.findFirstToken(JavadocUtil.java:200)
  at com.puppycrawl.tools.checkstyle.site.SiteUtil.getSinceVersionFromJavadoc(SiteUtil.java:727)
  at com.puppycrawl.tools.checkstyle.site.SiteUtil.getSinceVersion(SiteUtil.java:707)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertySinceVersionCell(PropertiesMacro.java:492)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertyRow(PropertiesMacro.java:233)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writeTablePropertiesRows(PropertiesMacro.java:187)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.writePropertiesTable(PropertiesMacro.java:130)
  at com.puppycrawl.tools.checkstyle.site.PropertiesMacro.execute(PropertiesMacro.java:102)
  at org.apache.maven.doxia.parser.AbstractParser.executeMacro(AbstractParser.java:145)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.processMacroEnd(XdocsTemplateParser.java:187)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.handleEndTag(XdocsTemplateParser.java:116)
  at org.apache.maven.doxia.parser.AbstractXmlParser.parseXml(AbstractXmlParser.java:238)
  at org.apache.maven.doxia.parser.AbstractXmlParser.parse(AbstractXmlParser.java:156)
  at org.apache.maven.doxia.parser.XhtmlBaseParser.parse(XhtmlBaseParser.java:92)
  at org.apache.maven.doxia.module.xdoc.XdocParser.parse(XdocParser.java:113)
  at com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser.parse(XdocsTemplateParser.java:76)
  at org.apache.maven.doxia.parser.AbstractParser.parse(AbstractParser.java:207)
  at com.puppycrawl.tools.checkstyle.internal.utils.XdocGenerator.generateXdocContent(XdocGenerator.java:68)
  ... 62 more

I fixed this CI failure @romani Sir.

Copy link
Member

@rnveach rnveach left a comment

Choose a reason for hiding this comment

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

Should be final change

else if (SUPER_CLASS_PROPERTIES_JAVADOCS.containsKey(propertyName)
|| TOKENS.equals(propertyName)
|| JAVADOC_TOKENS.equals(propertyName)) {
else if (TOKENS.equals(propertyName) || JAVADOC_TOKENS.equals(propertyName)) {
Copy link
Member

@rnveach rnveach Nov 12, 2023

Choose a reason for hiding this comment

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

Suggested change
else if (TOKENS.equals(propertyName) || JAVADOC_TOKENS.equals(propertyName)) {
else if (TOKENS.equals(propertyName)
|| JAVADOC_TOKENS.equals(propertyName)) {

restore original lining and indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure sir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rnveach Even After making these changes it is not updating sinceVersion.

Copy link
Member

Choose a reason for hiding this comment

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

@Rohanraj123 , restore formatting only

else if (TOKENS.equals(propertyName)
                || JAVADOC_TOKENS.equals(propertyName)) {

Copy link
Member

Choose a reason for hiding this comment

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

code looks good.

Copy link
Member

Choose a reason for hiding this comment

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

Even After making these changes it is not updating sinceVersion.

What do you mean?
It was updated at https://github.com/checkstyle/checkstyle/pull/13945/files#diff-eaff5fa3cb101145757a2bd9ebe2e805e8fd8057ae27f9e21ef91900cb7938cc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay got it thanks !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Rohanraj123 , restore formatting only

else if (TOKENS.equals(propertyName)
                || JAVADOC_TOKENS.equals(propertyName)) {

did it ! @romani Sir

@rnveach rnveach merged commit b5d2509 into checkstyle:master Nov 13, 2023
113 checks passed
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.

None yet

3 participants