简体   繁体   English

checkstyle 使用的默认规则是什么?

[英]What are the default rules used by checkstyle?

If I don't define a checkstyle config then a couple of checkstyle rules are executed by default, is there a list of default rules used by checkstyle?如果我没有定义 checkstyle 配置,则默认执行几个 checkstyle 规则,是否有 checkstyle 使用的默认规则列表?

This is how my maven config looks like:这就是我的 maven 配置的样子:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <failOnViolation>true</failOnViolation>
                    <consoleOutput>true</consoleOutput>
                    <logViolationsToConsole>true</logViolationsToConsole>
                </configuration>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

You can find the rules on official github https://github.com/checkstyle/checkstyle/tree/master/src/main/resources and read the descriptions on the official website https://checkstyle.sourceforge.io/checks.html You can find the rules on official github https://github.com/checkstyle/checkstyle/tree/master/src/main/resources and read the descriptions on the official website https://checkstyle.sourceforge.io/checks.html

The default configuration is using the predefined ruleset "Sun Microsystems Definition" in sun_checks.xml , see Maven Checkstyle Plugin docs :默认配置使用 sun_checks.xml 中的预定义规则集“Sun Microsystems Definition”,请参阅sun_checks.xml Checkstyle Plugin 文档

There are 2 predefined Checkstyle configuration definitions that ship with the Checkstyle Plugin, the Sun Microsystems Definition is selected by default. Checkstyle 插件附带了 2 个预定义的 Checkstyle 配置定义,默认选择 Sun Microsystems 定义。

  • sun_checks.xml - Sun Microsystems Definition (default). sun_checks.xml - Sun Microsystems 定义(默认)。
  • google_checks.xml - Google Definition. google_checks.xml - 谷歌定义。

The contents of the ruleset can be found at Checkstyle's GitHub repository .可以在Checkstyle 的 GitHub 存储库中找到规则集的内容。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM