java - Checkstyle - 我可以更改 MethodParamPad 的 `' (' should be on the previous line?` 规则吗?

标签 java checkstyle

在 checkstyle 中,MethodParamPad 生成消息 -

'('应该在上一行

例如,在我的代码中,它不喜欢

    schema.withProperty(propertyName, createStringType(propertyAnnotation, annotations.getAnnotationByClass
            (StringSchema.class)));

它想要:

    schema.withProperty(propertyName, createStringType(propertyAnnotation, annotations.getAnnotationByClass(
            StringSchema.class)));

这是到目前为止我的 checkstyle.xml 文件。

https://pastebin.com/2NXvzUjA

我怎样才能使它强制执行第一个片段,而不是第二个片段?

最佳答案

我认为您不能真正强制执行第二种样式,因为它会在调用 schema.getProperty 时失败。

但是,该规则有一个 allowLineBreaks 参数,您可以将其设置为 true 以使代码通过。 请参阅http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad

<module name="MethodParamPad">
    <property name="allowLineBreaks" value="true" />
</module>

关于java - Checkstyle - 我可以更改 MethodParamPad 的 `' (' should be on the previous line?` 规则吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45109089/

相关文章:

java - 为什么 CheckStyle 建议我使用 final 方法?

android - 当我在 Android Studio 中按下 Run Android Application 按钮时,我可以运行 checkstyle

java - int(primitive) 值未隐式转换为 long(primitive)

java - 如何禁止使用带有某些注释的类

java - [Android][RecyclerView] 方法不会覆盖或实现父类(super class)型的方法

java - JavaFX 2 中的组合框键值对

java - 类 '...' 必须声明为 'abstract' 。格纹

PMD、Findbugs 和 Checkstyle 的 Java 版本

java - eclim 不在 vim 中进行自动完成

java - Android 设备的内部版本号是否唯一?