Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable checkstyle warnings for missing final modifiers on lambdas?

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?

like image 494
marstran Avatar asked Sep 28 '22 09:09

marstran


1 Answers

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

like image 199
Astrogat Avatar answered Oct 13 '22 02:10

Astrogat