在 checkstyle 中,MethodParamPad
生成消息 -
'('应该在上一行
例如,在我的代码中,它不喜欢
schema.withProperty(propertyName, createStringType(propertyAnnotation, annotations.getAnnotationByClass
(StringSchema.class)));
它想要:
schema.withProperty(propertyName, createStringType(propertyAnnotation, annotations.getAnnotationByClass(
StringSchema.class)));
这是到目前为止我的 checkstyle.xml 文件。
我怎样才能使它强制执行第一个片段,而不是第二个片段?
最佳答案
我认为您不能真正强制执行第二种样式,因为它会在调用 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/