Skip to content

Compatibility with Checkstyle 10.22 #433

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

Open
Larcius opened this issue Apr 1, 2025 · 1 comment
Open

Compatibility with Checkstyle 10.22 #433

Larcius opened this issue Apr 1, 2025 · 1 comment

Comments

@Larcius
Copy link

Larcius commented Apr 1, 2025

Update dependency com.puppycrawl.tools:checkstyle to 10.22.0

This is in particular needed because of a breaking change in version 10.22.0:

JavadocVariable: new property 'accessModifiers' as substitution of 'scope' and 'excludeScope'

See https://checkstyle.org/releasenotes.html#Release_10.22.0

So it is no longer possible to simply override the version of com.puppycrawl.tools:checkstyle in other projects like this:

...
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-checkstyle-plugin</artifactId>
	<version>${maven-checkstyle-plugin.version}</version>
	<dependencies>
		<dependency>
			<groupId>com.puppycrawl.tools</groupId>
			<artifactId>checkstyle</artifactId>
			<version>10.22.0</version> <!-- using 10.21.4 was working though -->
		</dependency>
		<dependency>
			<groupId>io.spring.javaformat</groupId>
			<artifactId>spring-javaformat-checkstyle</artifactId>
			<version>0.0.43</version>
		</dependency>
	</dependencies>
	...
</plugin>
...

Larcius added a commit to Larcius/spring-javaformat that referenced this issue Apr 1, 2025
Larcius added a commit to Larcius/spring-javaformat that referenced this issue Apr 1, 2025
@wilkinsona
Copy link
Contributor

wilkinsona commented Apr 1, 2025

We can't upgrade to Checkstyle 10 as it requires Java 11 and Spring Java Format needs to support projects with a Java 8 baseline. Instead, we'll have to look at doing something similar to #395 and somehow tolerate the breaking change in Checkstyle 10.22.

For future reference, the current failure looks like this:

Caused by: java.lang.IllegalStateException: cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - cannot initialize module com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck - Property 'scope' does not exist, please check the documentation
        at io.spring.javaformat.checkstyle.SpringConfigurationLoader.createModule(SpringConfigurationLoader.java:87)
        at io.spring.javaformat.checkstyle.SpringConfigurationLoader.load(SpringConfigurationLoader.java:72)
        at io.spring.javaformat.checkstyle.SpringConfigurationLoader.load(SpringConfigurationLoader.java:58)
        at io.spring.javaformat.checkstyle.SpringChecks.finishLocalSetup(SpringChecks.java:103)
        at com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.configure(AbstractAutomaticBean.java:207)
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:479)
        at com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.configure(AbstractAutomaticBean.java:211)
        at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.createRootModule(CheckstyleAntTask.java:402)
        at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.realExecute(CheckstyleAntTask.java:298)
        at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.execute(CheckstyleAntTask.java:280)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        ... 37 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck - Property 'scope' does not exist, please check the documentation
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:160)
        at com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.configure(AbstractAutomaticBean.java:211)
        at io.spring.javaformat.checkstyle.SpringConfigurationLoader.initialize(SpringConfigurationLoader.java:96)
        at io.spring.javaformat.checkstyle.SpringConfigurationLoader.createModule(SpringConfigurationLoader.java:83)
        ... 51 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Property 'scope' does not exist, please check the documentation
        at com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.tryCopyProperty(AbstractAutomaticBean.java:237)
        at com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.configure(AbstractAutomaticBean.java:204)
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:155)
        ... 54 more

@wilkinsona wilkinsona changed the title Update dependency com.puppycrawl.tools:checkstyle to v10.22.0 Compatibility with Checkstyle 10.22 Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants