简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM