openrewrite / openrewrite/rewrite

Java recipe `ChangePackage` does not work with Kotlin on non-nested package `mu`

Open
#4,644 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What version of OpenRewrite are you using?

I am using

  • OpenRewrite 2.21.1 (rewrite-recipe-bom)

How are you running OpenRewrite?

I'm running a unit test in Java.

What is the smallest, simplest way to reproduce the problem?

import org.junit.jupiter.api.Test;
import org.openrewrite.java.ChangePackage;
import org.openrewrite.kotlin.KotlinParser;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.kotlin.Assertions.kotlin;

class ChangePackageImportTest implements RewriteTest {

    @Test
    void checkKotlinPackageImport() {
        rewriteRun(
                spec -> spec.recipes(
                                new ChangePackage(
                                        "mu",
                                        "io.github.oshai.kotlinlogging",
                                        null
                                )
                        )
                        .parser(KotlinParser.builder()),
                kotlin(
                        "import mu.KotlinLogging",
                        "import io.github.oshai.kotlinlogging.KotlinLogging"
                )
        );
    }
}

What did you expect to see?

The test passes

What did you see instead?

The test fails without any changes

Are you interested in contributing a fix to OpenRewrite?

I don't think I have the time at the moment, to look into this issue.

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 supplied ChangePackageImportTest reproducer, using ChangePackage and KotlinParser as the entry points. Inspect how ChangePackage handles the non-nested Kotlin import and run the unit test; done means the import changes from mu.KotlinLogging to io.github.oshai.kotlinlogging.KotlinLogging.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.