Nik*_*hil 6 checkstyle maven maven-checkstyle-plugin google-java-format
我正在寻找配置 google_checks 以4 spaces
在 Maven Checkstyle 插件中使用的方法。我将indentSize
配置参数设置为4,但是不起作用。有配置选项来设置这个吗?我不想拥有自己的版本,google_checks.xml
只是缩进 4 个空格。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<artifactId>checkstyle</artifactId>
<groupId>com.puppycrawl.tools</groupId>
<version>8.36.1</version>
</dependency>
</dependencies>
<configuration>
<configLocation>google_checks.xml</configLocation>
<indentSize>4</indentSize>
<failsOnError>true</failsOnError>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
更新:似乎没有办法有一个与maven-checkstyle-plugin
,Checkstyle with google_checks
和兼容的单一格式Intellij with google_java_format
。有人能够实现这一目标吗?
目前,Checkstyle 不支持此类配置组合。
\n以下是一些相关的 GitHub 问题:
\n如何扩展/覆盖现有配置(sun、google) \xc2\xb7 Issue #4484 \xc2\xb7 checkstyle/checkstyle。
\n创建配置 \xc2\xb7 的继承/覆盖和组合/扩展的概念 Issue #2873 \xc2\xb7 checkstyle/checkstyle。
\n有一个非常简单的解决方法可以覆盖配置文件的某些检查:将单个 Checkstyle Maven 插件执行拆分为两个执行:
\n此处还解释了此解决方法:创建配置的继承/覆盖和组合/扩展的概念 \xc2\xb7 问题 #2873 \xc2\xb7 checkstyle/checkstyle:注释。
\npom.xml
插件/build/pluginManagement/plugins
定义:
<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-checkstyle-plugin</artifactId>\n <version>3.1.2</version>\n <dependencies>\n <dependency>\n <groupId>com.puppycrawl.tools</groupId>\n <artifactId>checkstyle</artifactId>\n <version>8.43</version>\n </dependency>\n </dependencies>\n</plugin>\n
Run Code Online (Sandbox Code Playgroud)\n插件/build/plugins
定义:
<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-checkstyle-plugin</artifactId>\n <executions>\n <execution>\n <id>check-google-checks</id>\n <phase>validate</phase>\n <goals>\n <goal>check</goal>\n </goals>\n <configuration>\n <configLocation>google_checks.xml</configLocation>\n <suppressionsLocation>maven-checkstyle-suppressions-google_checks.xml</suppressionsLocation>\n <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>\n </configuration>\n </execution>\n <execution>\n <id>check-custom-checks</id>\n <phase>validate</phase>\n <goals>\n <goal>check</goal>\n </goals>\n <configuration>\n <configLocation>maven-checkstyle-custom_checks.xml</configLocation>\n </configuration>\n </execution>\n </executions>\n <configuration>\n <failsOnError>true</failsOnError>\n <violationSeverity>warning</violationSeverity>\n <includeTestSourceDirectory>true</includeTestSourceDirectory>\n </configuration>\n</plugin>\n
Run Code Online (Sandbox Code Playgroud)\nmaven-checkstyle-suppressions-google_checks.xml
<?xml version="1.0"?>\n<!DOCTYPE suppressions PUBLIC\n "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"\n "https://checkstyle.org/dtds/suppressions_1_2.dtd">\n<suppressions>\n <suppress checks="Indentation" files="." />\n</suppressions>\n
Run Code Online (Sandbox Code Playgroud)\nmaven-checkstyle-custom_checks.xml
<?xml version="1.0"?>\n<!DOCTYPE module PUBLIC\n "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"\n "https://checkstyle.org/dtds/configuration_1_3.dtd">\n<module name="Checker">\n <module name="TreeWalker">\n <module name="Indentation">\n <property name="basicOffset" value="4" />\n <property name="braceAdjustment" value="4" />\n <property name="caseIndent" value="4" />\n <property name="throwsIndent" value="4" />\n <property name="lineWrappingIndentation" value="4" />\n <property name="arrayInitIndent" value="4" />\n </module>\n </module>\n</module>\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
2203 次 |
最近记录: |