openrewrite / openrewrite/rewrite-migrate-java

`PreferJavaUtilFunction` should not convert when used specifically as Guava type

Open
#436 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug guava
Dominant language
Java
Stars
156
Forks
130
Avg merge
20h 57m
Merged PRs (30d)
21

Description

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

                <plugin>
                    <groupId>org.openrewrite.maven</groupId>
                    <artifactId>rewrite-maven-plugin</artifactId>
                    <version>5.23.1</version>
                    <configuration>
                        <activeRecipes>
                            <recipe>org.openrewrite.java.migrate.guava.NoGuavaJava11</recipe>
                        </activeRecipes>
                        <failOnDryRunResults>true</failOnDryRunResults>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.openrewrite.recipe</groupId>
                            <artifactId>rewrite-migrate-java</artifactId>
                            <version>2.10.0</version>
                        </dependency>
                    </dependencies>
                </plugin>

What is the Problem?

Example: in Collections2.transform(someList, com.google.common.base.Function) only the function is converted to a jdk equivalent. This breaks the build because transform only accepts a guava Function.

Are you interested in contributing a fix to OpenRewrite?

No, sorry

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the org.openrewrite.java.migrate.guava.NoGuavaJava11 recipe configured through the Maven plugin, and reproduce the Collections2.transform example using a Guava Function. Trace how PreferJavaUtilFunction handles the explicitly Guava-typed argument. Done means the Guava Function remains unchanged in that context and the Maven build succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.