How can I turn off warnings about missing final modifiers on lambda?

I get warnings about missing missing final modifiers when writing lambdas in Java 8. I want to get warnings when writing regular methods, but not in lambdas.

For example, adding up a list of BigDecimals, for example:

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

provides the following warnings:

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

Is there a way to make Checkstyle ignore this only when writing lambdas?

+5
source share
1 answer

What version of checkstyle are you using. This should have been fixed in version 6.5, so if you are using an earlier version, this is a known bug.

source: https://github.com/checkstyle/checkstyle/issues/747

+4
source

All Articles