I am getting checkstyle warnings for missing final modifiers when writing lambdas in Java 8. I want the warnings when writing normal methods, but not in lambdas.
For example, summing a list of BigDecimals like this:
values.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b));
gives me the following checkstyle 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?
What version of checkstyle are you running. This should have been fixed in version 6.5, so if you are running an earlier version it's a known bug.
source: https://github.com/checkstyle/checkstyle/issues/747
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With