Maven和Eclipse使用的Checkstyle配置 [英] Checkstyle config used by Maven and Eclipse

查看:461
本文介绍了Maven和Eclipse使用的Checkstyle配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Maven和Eclipse中使用相同的Checkstyle配置文件.模块SuppressionCommentFilter在Eclipse中按预期工作,但是Maven报告 不允许TreeWalker作为SuppressionCommentFilter的父级 如果我将其从TreeWalker移至Checker,错误将消失,但Checkstyle不会处理忽略注释.我在Eclipse中使用Checkstyle 8.12,但没有找到在Maven中使用6.18以外的方法.由于此模块自3.5以来一直是Checkstyle的一部分,所以我不认为这可能是问题所在.有什么建议吗?

I am try to use the same Checkstyle configuration file with both Maven and Eclipse. The module SuppressionCommentFilter works as expected in Eclipse, but Maven reports TreeWalker is not allowed as a parent of SuppressionCommentFilter If I move it from TreeWalker to Checker the error goes away, but Checkstyle does not process the ignore comments. I am using Checkstyle 8.12 with Eclipse, but have not found a way to use other than 6.18 with Maven. Since this module had been part of Checkstyle since 3.5 I don't see how that could be the problem. Any suggestions what is wrong?

<module name="Checker">
<property name="severity" value="warning" />
<module name="TreeWalker">
    <property name="tabWidth" value="4" />
    <module name="SuppressionCommentFilter" />


Mark询问外观如何,所以这是这段代码.


Mark asked what the looks like, so here is that piece of code.

            <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>
        </plugin>

pom和Checkstyle配置文件除
之外均正常工作 如果它是Treewalker的子代,我会从Maven插件得到错误,但不会从Eclipse插件得到错误,但是我只能让它与Eclipse插件一起使用.

The pom and Checkstyle config file are all working correctly other than the
If it is a child of Treewalker I get the error from the Maven plugin, but not from the Eclipse plugin, however I can only get it to work with the Eclipse plugin.

推荐答案

我在Eclipse中使用Checkstyle 8.12,但未找到在Maven中使用6.18以外的方法

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

您必须重写maven中的依赖关系以引入Checkstyle的较新版本.默认情况下,maven插件将仅使用6.18,但可以被较新的版本覆盖.

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.

请参见 https://maven.apache. org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html

这篇关于Maven和Eclipse使用的Checkstyle配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆