简体   繁体   English

Eclipse Checkstyle插件显示与maven-checkstyle-plugin不同的结果

[英]Eclipse Checkstyle Plugin showin different results that maven-checkstyle-plugin

Recently I am trying to configure Checkstyle on Jenkins (which is using maven checkstyle results). 最近,我试图在Jenkins上配置Checkstyle(正在使用maven checkstyle结果)。 My problem is that eclipse checkstyle is showing different number of checkstyle violations. 我的问题是,eclipse checkstyle显示了不同数量的checkstyle违规。 I am using the same xml file with checkstyle rules for both maven and eclipse. 我对maven和eclipse使用同一个带有checkstyle规则的xml文件。

Eclipse Checkstyle Plugin 8.12.0 - ~500 violations maven-checkstyle-plugin 3.0.0 - over 5000 violations Eclipse Checkstyle插件8.12.0-约500次违反Maven-checkstyle-plugin 3.0.0-超过5000次违反

For eclipse errors I can see mostly NPath Complexity and "String appears X times in the file" warnings. 对于eclipse错误,我主要可以看到NPath复杂性和“字符串在文件中出现X次”的警告。

For Maven chekstyle 2000 warnings are "Line has trailing spaces" (No such warning in eclipse). 对于Maven chekstyle 2000,警告为“行尾有空格”(日食中无此类警告)。 There are also many ConstantNameCheck, RegexpSinglelineJavaCheck, VisibilityModifierCheck warnings. 也有许多ConstantNameCheck,RegexpSinglelineJavaCheck,VisibilityModifierCheck警告。

I assume that both plugins works differently, but is there any way to make it show similar warnings? 我认为这两个插件的工作方式不同,但是有什么办法可以使它显示类似的警告?

For Example: In simple project module I got 4 eclipse violations for NPath complexity. 例如:在简单的项目模块中,由于NPath的复杂性,我遇到了4次月食违规。 For file TestHandler.java it is showing "NPath Complexity is 13 allowed is 8". 对于文件TestHandler.java,它显示“ NPath复杂度为13,允许为8”。 In maven I got 6 violations and most of them are different. 在行家中,我有6次违规,大多数违规。 Only similar one is saying that the same phrase in TestHandler.java "NPath Complexity is 13 allowed is 4". 唯一相似的说法是TestHandler.java中的同一短语“允许的NPath复杂度为13为4”。

This is how checking compexity looks in xml that both checkstyles are using: 这是两种样式都使用的xml中检查兼容性的方式:

</module>
<module name="CyclomaticComplexity">
  <property name="max" value="6" />
</module>
<module name="NPathComplexity">
  <property name="max" value="8" />
</module>

I run maven chestyle just by using mvn clean install checkstyle:checkstyle or on jenkis. 我只是通过使用mvn clean install checkstyle:checkstyle或在jenkis上运行maven chestyle。 I am using most basic confuration of maven plugin in pom. 我在pom中使用了Maven插件的最基本配置。 More information can be provided if needed. 如果需要,可以提供更多信息。

I did changes in the main pom as you proposed. 我按照您的建议对主要pom进行了更改。 I also removed Javadoc violations from checkstyle.xml file. 我还从checkstyle.xml文件中删除了Javadoc违规行为。 Currently on eclipse I got ~510, on Intelij ~3100 and in Maven checkstyle ~ 3800. As I checked there are differences in violations on each of these three. 目前在Eclipse上我有〜510,在Intelij上有〜3100,在Maven Checkstyle中有〜3800。当我检查时,这三个方面的违规情况有所不同。 This is snippet of my POM configuration for checkstyle: 这是我的checkstyle POM配置的片段:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>3.0.0</version>
      <dependencies>
        <dependency>
          <groupId>com.puppycrawl.tools</groupId>
          <artifactId>checkstyle</artifactId>
          <version>6.18</version>
        </dependency>
      </dependencies>
      <executions>
      <execution>
      <id>validate</id>
      <phase>validate</phase>
      <configuration>
        <configLocation>common\code-style\checkstyle2.xml</configLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
      </configuration>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
      </executions>
    </plugin> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置Eclipse Checkstyle插件以使用与maven-checkstyle-plugin相同的规则 - How to configure the Eclipse Checkstyle plugin to use the same rules used by the maven-checkstyle-plugin 如何设计用于 YAML 文件验证的 maven-checkstyle-plugin? - How to design maven-checkstyle-plugin for YAML file validation? maven-checkstyle-plugin 不适用于 macOS 上的 google_checks.xml - maven-checkstyle-plugin not working with google_checks.xml on macOS NetBeans(Maven)项目:checkstyle-beans与maven-checkstyle-plugin - NetBeans (maven) project: checkstyle-beans vs maven-checkstyle-plugin 我可以使用checkstyle,maven-checkstyle-plugin和google_checks.xml启用抑制吗? - Can I enable suppressions with checkstyle, the maven-checkstyle-plugin and google_checks.xml? 使用带有maven-checkstyle-plugin的checkstyle / google_checks.xml时出错 - Error using checkstyle/google_checks.xml with maven-checkstyle-plugin maven-checkstyle-plugin:3.0.0:check: checkstyle 配置期间失败:无法初始化模块 StrictDuplicateCode - maven-checkstyle-plugin:3.0.0:check: Failed during checkstyle configuration: cannot initialize module StrictDuplicateCode 未找到插件“org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0” - Plugin 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0' not found 自定义Maven Checkstyle插件 - Customise maven checkstyle plugin eclipse checkstyle插件:CustomImportOrder - eclipse checkstyle plugin : CustomImportOrder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM