Repository: scala-steward-org/scala-steward (scala)

Issue:
Scalafix migration for cats-core is used in log4cats-core update
See https://github.com/tpolecat/natchez/pull/592. The PR updates [org.typelevel:log4cats-core](https://github.com/typelevel/log4cats) and applies the following Scalafix migration for cats-core:
https://github.com/scala-steward-org/scala-steward/blob/e94fc77485a2beb9c366015507dcda1393e25cda/modules/core/src/main/resources/scalafix-migrations.conf#L147-L154
This migration should not match log4cats-core.

Pull request:
Closes https://github.com/scala-steward-org/scala-steward/issues/2682.

Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinder.scala b/modules/core/src/main/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinder.scala
index 8a91b9724a..9792e8c88d 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinder.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinder.scala
@@ -17,6 +17,7 @@
 package org.scalasteward.core.edit.scalafix
 
 import cats.syntax.all._
+import java.util.regex.Pattern
 import org.scalasteward.core.data.Update
 import org.scalasteward.core.edit.scalafix.ScalafixMigration.ExecutionOrder
 
@@ -26,7 +27,8 @@ final class ScalafixMigrationsFinder(migrations: List[ScalafixMigration]) {
       .filter { migration =>
         update.groupId === migration.groupId &&
         migration.artifactIds.exists { re =>
-          update.artifactIds.exists(artifactId => re.r.findFirstIn(artifactId.name).isDefined)
+          val pattern = Pattern.compile(re)
+          update.artifactIds.exists(artifactId => pattern.matcher(artifactId.name).matches())
         } &&
         update.currentVersion < migration.newVersion &&
         update.nextVersion >= migration.newVersion


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinderTest.scala b/modules/core/src/test/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinderTest.scala
index a5ead0781b..829751cf6a 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinderTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/edit/scalafix/ScalafixMigrationsFinderTest.scala
@@ -9,7 +9,7 @@ import org.scalasteward.core.util.Nel
 class ScalafixMigrationsFinderTest extends FunSuite {
   test("findMigrations") {
     val update = ("org.typelevel".g % "cats-core".a % "2.1.0" %> "2.2.0").single
-    val migrations = scalafixMigrationsFinder.findMigrations(update)
+    val obtained = scalafixMigrationsFinder.findMigrations(update)
     val expected = (
       List(
         ScalafixMigration(
@@ -25,6 +25,13 @@ class ScalafixMigrationsFinderTest extends FunSuite {
       ),
       List()
     )
-    assertEquals(migrations, expected)
+    assertEquals(obtained, expected)
+  }
+
+  test("findMigrations: pattern must match whole artifactId") {
+    val update = ("org.typelevel".g % "log4cats-core".a % "2.1.1" %> "2.4.0").single
+    val obtained = scalafixMigrationsFinder.findMigrations(update)
+    val expected = (List(), List())
+    assertEquals(obtained, expected)
   }
 }