Links

Use explicit types on lambda arguments

org.openrewrite.java.cleanup.ExplicitLambdaArgumentTypes
Adds explicit types on lambda arguments, which are otherwise optional. This can make the code clearer and easier to read. This does not add explicit types on arguments when the lambda has one or two parameters and does not have a block body, as things are considered more readable in those cases. For example, stream.map((a, b) -> a.length); will not have explicit types added.

Tags

  • RSPEC-2211

Source

  • groupId: org.openrewrite
  • artifactId: rewrite-java
  • version: 7.40.6

Contributors

Usage

This recipe has no required configuration parameters and comes from a rewrite core library. It can be activated directly without adding any dependencies.
Gradle
Maven POM
Maven Command Line
build.gradle
plugins {
id("org.openrewrite.rewrite") version("5.40.4")
}
rewrite {
activeRecipe("org.openrewrite.java.cleanup.ExplicitLambdaArgumentTypes")
}
repositories {
mavenCentral()
}
pom.xml
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>4.45.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.cleanup.ExplicitLambdaArgumentTypes</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
You will need to have Maven installed on your machine before you can run the following command.
shell
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.activeRecipes=org.openrewrite.java.cleanup.ExplicitLambdaArgumentTypes

See how this recipe works across multiple open-source repositories

Moderne Link Image
The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.