如何禁用lambdas上缺少最终修饰符的checkstyle警告?

时间:2015-07-08 08:16:11

标签: java lambda checkstyle

在Java 8中编写lambdas时,我收到了缺少最终修饰符的checkstyle警告。我在编写普通方法时需要警告,但在lambdas中没有。

例如,将BigDecimals列表总结如下:

values.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b));

给了我以下检查式警告:

- Variable 'a' should be declared final.
- Variable 'b' should be declared final.

有没有办法让Checkstyle在写lambdas时忽略它?

1 个答案:

答案 0 :(得分:4)

您正在运行什么版本的checkstyle。这应该已在6.5版本中修复,因此如果您运行的是早期版本,则这是一个已知错误。

来源:https://github.com/checkstyle/checkstyle/issues/747