Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Use String.equals() on String literals" should not make changes for Groovy #140

Closed
moderne-meeseeks bot opened this issue Jul 21, 2023 · 2 comments · Fixed by #142
Closed

"Use String.equals() on String literals" should not make changes for Groovy #140

moderne-meeseeks bot opened this issue Jul 21, 2023 · 2 comments · Fixed by #142
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@moderne-meeseeks
Copy link

Problem

Groovy has operator overloading, meaning == is preferred there for String comparisons.

Expected behavior

No change when running "Use String.equals() on String literals" on Groovy files.

Example diff

From: guides/micronaut-microservices-services-discover-eureka/bookrecommendation/groovy/src/test/groovy/example/micronaut/BookControllerSpec.groovy

    then:
    books.size() == 1
-        books[0].name == "Building Microservices"
+        "Building Microservices".equals(books[0].name)
}
}

Recipes in example diff:

  • org.openrewrite.staticanalysis.StringLiteralEquality

References:

  • View original result
  • Recipe ID: org.openrewrite.staticanalysis.StringLiteralEquality
  • Recipe Name: Use String.equals() on String literals
  • Repository: micronaut-projects/micronaut-guides/master
  • Created at Fri Jul 21 2023 14:07:13 GMT+0200 (Central European Summer Time)

This issue originally created by @timtebeek on: https://github.com/moderneinc/support-app/issues/6

@moderne-meeseeks moderne-meeseeks bot added the bug Something isn't working label Jul 21, 2023
@moderne-meeseeks
Copy link
Author


This comment originially written by @ on:

@timtebeek timtebeek transferred this issue from openrewrite/rewrite Jul 21, 2023
@timtebeek timtebeek moved this to Backlog in OpenRewrite Jul 21, 2023
@timtebeek
Copy link
Contributor

Fix likely requires something similar to what we already have for Kotlin.

TreeVisitor<?, ExecutionContext> preconditions = Preconditions.and(Preconditions.not(new KotlinFileChecker<>()),

@timtebeek timtebeek added the good first issue Good for newcomers label Jul 21, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Jul 27, 2023
@timtebeek timtebeek self-assigned this Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant