gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 07:53:06 25 4
gpt4 key购买 nike

在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com