[英]Checkstyle issuing an indentation warning on an annotation?
我有一个注释:
@ComponentScan(
basePackages = {
"com.example.foo",
"com.example.bar"
} // <--- false positive reported in this line
)
public class FooBar extends WebMvcConfigurerAdapter {
...
}
和Checkstyle配置:
<module name="AnnotationUseStyle" />
<module name="Indentation">
<property name="basicOffset" value="2" />
<property name="braceAdjustment" value="0" />
<property name="caseIndent" value="2" />
</module>
当我通过Checkstyle运行我的项目时,我收到一个错误,指出“在缩进级别2指定子级而不是正确的缩进,4”。 这是我上面代码示例的第5行引用,即basePackages
属性的结束括号。
我需要对Checkstyle进行哪些配置更改才能使此注释正确验证?
这是checkstyle中的一个已知问题: github.com/checkstyle/checkstyle/issues/553
作为解决方法,您可以将lineWrappingIndentation属性设置为零:
<module name="Indentation">
<property name="lineWrappingIndentation" value="0"/>
</module>
但在这种情况下,您还需要在换行后删除额外的缩进,例如
return getCalculator().
calculate(...);
代替
return getCalculator().
calculate(...);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.