Remove Lambda Expression Braces


Property Value
First seen in jSparrow version 2.0.0
Minimum Java version 8
Remediation cost 5 min
Links S1602


If the body of the lambda statement contains only a single expression, the braces are optional. It can be reduced to a lambda expression.

This is comparable to if-statements or loops with a single expression inside their body, where braces are also optional.


This rule provides an easier-to read alternative to filter items in a list.

Requirement & Tags


Java 8

Code Changes


public Function<Function, Function> f = (Function function) -> {
    return function.compose(function);


public Function<Function, Function> f = (Function function) -> function.compose(function);

Automatic Application of This Rule

The automatic application of this rule is supported in the following jSparrow version: