Google Java 样式的检查样式规则

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22841805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 18:17:46  来源:igfitidea点击:

Checkstyle rules for Google Java Style

javacoding-stylecheckstyle

提问by deamon

Is there a Checkstyle rule file with the Google Java Style?

是否有带有Google Java 样式的 Checkstyle 规则文件?

回答by deamon

The Google Summer of Code projectto create such a file implies, that it doesn't exist yet.

用于创建此类文件的Google Summer of Code 项目暗示它尚不存在。

回答by user2432405

回答by Markus Schulte

If you have a maven-project, you can easily integrate google_checks (you have to use at least maven-checkstyle-pluginversion 2.17)

如果你有一个 maven-project,你可以很容易地集成 google_checks(你必须至少使用maven-checkstyle-plugin2.17 版本)

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>2.17</version>
  <configuration>
    <configLocation>google_checks.xml</configLocation>
  </configuration>
</plugin>

Executing checkstyle will use google_checks, e.g. do

执行 checkstyle 将使用 google_checks,例如 do

mvn checkstyle:checkstyle

Version-background

版本背景

Checkstyle-project integrates google_checks from version 6.9on. Maven-checkstyle-plugin version 2.17. is the first one, which is released after checkstyle6.9 (actually it uses checkstyle6.11.2). So, maven-checkstyle-plugin2.17 is the first version of this plugin, which actually ships with google_checks and provides it without any other dependency.

Checkstyle-project 从6.9 版开始集成了 google_checks 。Maven-checkstyle-plugin 版本 2.17。是第一个,在 checkstyle6.9 之后发布(实际上是使用checkstyle6.11.2)。因此,maven-checkstyle-plugin2.17 是该插件的第一个版本,它实际上与 google_checks 一起提供,并且没有任何其他依赖项。