openrewrite / openrewrite/rewrite-static-analysis

Common static analysis recipe against micronaut-core drops Kotlin `override` and `companion` keywords

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug kotlin
Dominant language
Java
Stars
62
Forks
112
Avg merge
1d 19h
Merged PRs (30d)
40

Description

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.1.15+
  • Moderne platform
  • rewrite-static-analysis v1.0.5+

How are you running OpenRewrite?

Moderne platform;
running https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CommonStaticAnalysis
against https://app.moderne.io/organizations/micronaut-projects/micronaut-core?branch=4.0.x&origin=github.com
to produce https://github.com/micronaut-projects/micronaut-core/compare/4.0.x...timtebeek:micronaut-core:refactor/common-static-analysis-issues

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

@Internal
@Experimental
class DelegatingContextContinuation(
    private val continuation: Continuation<Any?>,
    private val coroutineContext: CoroutineContext
) : Continuation<Any?>, CoroutineStackFrame {

-    override val callerFrame: CoroutineStackFrame?
+    val  callerFrame: CoroutineStackFrame?
        get() = continuation as? CoroutineStackFrame

-    override fun getStackTraceElement(): StackTraceElement? = null
+     fun getStackTraceElement(): StackTraceElement? = null

-    override val context: CoroutineContext
+    val  context: CoroutineContext
        get() = coroutineContext

-    override fun resumeWith(result: Result<Any?>) {
+     fun resumeWith(result: Result<Any?>) {
        continuation.resumeWith(result)
    }
}

What did you expect to see?

override val, override fun and companion object retained.
https://github.com/moderneinc/moderne-ui/issues/2843 is making it hard to show which recipes are involved exactly, as the full diff is large.

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.staticanalysis.CommonStaticAnalysis recipe and reproduce it against the Kotlin example shown in the issue. Compare the generated diff with the expected retention of override and companion keywords; done means those declarations remain intact while the recipe still applies its other changes.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.