Skip to content

chore(deps): update dependency com.puppycrawl.tools:checkstyle to v14 - #631

Open
muntasir-396 wants to merge 1 commit into
SpongePowered:trunkfrom
muntasir-396:update-checkstyle-14
Open

muntasir-396 wants to merge 1 commit into
SpongePowered:trunkfrom
muntasir-396:update-checkstyle-14

Conversation

@muntasir-396

Copy link
Copy Markdown

Update Checkstyle dependency from 12.3.1 to 14.4.0.

Also removes the obsolete FilteringWriteTag module from .checkstyle/checkstyle.xml, which had tagSeverity="ignore" and is incompatible with Checkstyle 13+ due to ca.stellardrift:stylecheck calling ScopeUtil.getSurroundingScope whose return type changed in Checkstyle 13.

All Checkstyle tasks (./gradlew checkstyleMain checkstyleTest) pass cleanly with 0 errors.

This also allows Configurate to run cleanly against latest Checkstyle snapshots in Checkstyle regression test suite (checkstyle/checkstyle#22310).

Remove obsolete FilteringWriteTag module from Checkstyle configuration as it is incompatible with Checkstyle 13+.

@romani romani left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Items

<module name="ExplicitInitialization"/>

<!-- https://checkstyle.org/config_javadoc.html#WriteTag -->
<!-- https://gitlab.com/stellardrift/stylecheck/-/blob/dev/src/main/java/ca/stellardrift/stylecheck/FilteringWriteTag.java -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please review gradle config.
There likely extra dependency jar user , extra check is at extension of Checkstyle.
So it should stay.

We just need to find how to run validation of Checkstyle on this project by gradle

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@romani Thank you for the review!

I checked the Gradle configuration in build-logic/src/main/groovy/org.spongepowered.configurate.build.component.gradle, and stylecheck is indeed added to the classpath:

dependencies {
    checkstyle(libs.stylecheck) // ca.stellardrift:stylecheck:0.2.1
}

However, running ./gradlew checkstyleMain checkstyleTest with Checkstyle 14 and FilteringWriteTag present fails due to two breaking changes in Checkstyle 14:

  1. tagSeverity property removed in Checkstyle 14 (Issue #21080):

    Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Property 'tagSeverity' does not exist, please check the documentation
    
  2. Binary incompatibility in ScopeUtil (Issue #13351):
    Even after removing tagSeverity, ca.stellardrift:stylecheck:0.2.1 (the latest release on Central, published May 2023) was compiled against Checkstyle 10.11.0. Checkstyle 14 changed ScopeUtil.getSurroundingScope(DetailAST) return type from Scope to Optional<Scope>, resulting in:

    Caused by: java.lang.NoSuchMethodError: 'com.puppycrawl.tools.checkstyle.api.Scope com.puppycrawl.tools.checkstyle.utils.ScopeUtil.getSurroundingScope(com.puppycrawl.tools.checkstyle.api.DetailAST)'
        at ca.stellardrift.stylecheck.FilteringWriteTag.visitToken(FilteringWriteTag.java:106)
        at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:382)
    

Since ca.stellardrift:stylecheck does not yet have a Checkstyle 14-compatible release, FilteringWriteTag cannot run under Checkstyle 14. When FilteringWriteTag is removed or commented out, ./gradlew checkstyleMain checkstyleTest completes with BUILD SUCCESSFUL across all modules.

Would you prefer:

  1. Leaving FilteringWriteTag commented out in .checkstyle/checkstyle.xml with a <!-- TODO: re-enable once stylecheck is updated for Checkstyle 14 --> comment, or
  2. Keeping it removed as in the current diff?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In checkstyle CI we should remove this Check.
At this PR, we should ask authors what is preferred, may be new WriteTag after big breaking changes that we already released is what they need.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you see a functional reason why this FilteringWriteTag is required? In comparison to standard Checks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@romani Yes, FilteringWriteTag adds two features that standard WriteTag lacks:

  1. minimumScope="protected": Only enforces @since on public and protected API, ignoring private and package-private members (standard WriteTag flags all).
  2. ignoredAnnotations: Automatically skips @Override and @Test methods.

Because of this, standard WriteTag would produce false positives across their private and overridden methods.

  • Checkstyle CI: Already green because FilteringWriteTag is removed on my branch.
  • Configurate PR: We can ask Configurate authors if they prefer commenting it out until stylecheck updates for v14, or removing it for now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this PR please restore FilteringWriteTag and do update for stylecheck to use latest version of Checkstyle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Oh, FilteringWriteTag has execution problems in latest checkstyle. We need mainters guidance and what is ok approach to move forward

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zml2008, please share your thoughts on how to move forward?

This branch has not been deployed

No deployments
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