首页 > 解决方案 > 无法让 IntelliJ 代码样式匹配 checkstyle 配置

问题描述

我正在将 checkstyle 用于我正在处理的 Java 项目,并且我有一个checkstyle.xml我很满意的。但是,我发现一个地方不符合我的 IntelliJ 代码样式规则。这是一个例子。

IntelliJ 认为它的格式应该如下:

thisIsALongFunctionWithMultipleParameters(parameter1,
        andHereIsASecondFunctionWithMultipleParameters(parameter1,
                parameter2));

但是,我的 checkstyle 失败了,似乎认为它应该是这样的:

thisIsALongFunctionWithMultipleParameters(parameter1,
        andHereIsASecondFunctionWithMultipleParameters(parameter1,
        parameter2));

老实说,我真的不在乎使用哪个,但我确实希望他们同意。这是我的相关部分checkstyle.xml

<module name="Indentation">
    <property name="lineWrappingIndentation" value="8" />     
    <property name="throwsIndent" value="8" />
    <property name="forceStrictCondition" value="true" />
</module>

Checkstyle 似乎将其视为简单的换行,因此我们应该有一致的 8 个空格缩进。IntelliJ 将其视为两个嵌套函数,每个函数都需要一个额外的缩进。知道我需要在 IntelliJ 中更改哪些设置以使其保持一致吗?或者如何改变我checkstyle.xml的适应?

标签: intellij-ideacheckstyle

解决方案


推荐阅读