Checkstyle config used by Maven and Eclipse

試著忘記壹切 提交于 2019-12-02 13:16:58

I am using Checkstyle 8.12 with Eclipse, but have not found a way to use other than 6.18 with Maven

You must override the dependency in maven to bring in newer versions of Checkstyle. By default, the maven plugin will only use 6.18 but it can be overridden for newer versions.

See https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html

It appears that you have defined checkstyle as dependency and not as plugin.

Using the guide at Apache Maven Checkstyle I was able to use checkstyle for my personal projects. This is a snippet from the plugins section of my pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>verify-style</id>
            <phase>process-classes</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <logViolationsToConsole>true</logViolationsToConsole>
        <configLocation>yourcheckstylexmlhere.xml</configLocation>
    </configuration>
</plugin>

Maskime on GitHub says:

Dear reader if you googled your way here, like I did, the solution is to move the <module name="SuppressionCommentFilter"/> under the TreeWalker module.

I have tried this fix with the version you're using aswell and it does not give the error anymore.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!