Repository: scala-steward-org/scala-steward
Pull request #1604 (2020-09-07 13:20:36)

Ignore "scala" as search term in the "relaxed" heuristic

codecov[bot]: # [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=h1) Report
> Merging [#1604](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=desc) into [master](https://codecov.io/gh/scala-steward-org/scala-steward/commit/edd523c4815b27e2e8fae0ff4003c29e2c945b91?el=desc) will **increase** coverage by `0.05%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604/graphs/tree.svg?width=650&height=150&src=pr&token=udzMsc1Dne)](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1604      +/-   ##
==========================================
+ Coverage   70.28%   70.33%   +0.05%     
==========================================
  Files         113      112       -1     
  Lines        1780     1780              
  Branches       50       52       +2     
==========================================
+ Hits         1251     1252       +1     
+ Misses        529      528       -1     
```


| [Impacted Files](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...a/org/scalasteward/core/edit/UpdateHeuristic.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9lZGl0L1VwZGF0ZUhldXJpc3RpYy5zY2FsYQ==) | `100.00% <100.00%> (ø)` | |
| [...la-2.12/org/scalasteward/mill/plugin/package.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604/diff?src=pr&el=tree#diff-bW9kdWxlcy9taWxsLXBsdWdpbi9zcmMvbWFpbi9zY2FsYS0yLjEyL29yZy9zY2FsYXN0ZXdhcmQvbWlsbC9wbHVnaW4vcGFja2FnZS5zY2FsYQ==) | | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=footer). Last update [edd523c...023a620](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1604?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/README.md b/README.md
index f604860f..b4fda054 100644
--- a/README.md
+++ b/README.md
@@ -151,9 +151,9 @@ Consider creating PR to add your company to the list and join the community.
 * [Lightbend](https://www.lightbend.com/)
 * [Ocado Technology](https://ocadotechnology.com/)
 * [PlayQ](https://www.playq.com/)
+* [Precog](https://precog.com/)
 * [Rewards Network](https://www.rewardsnetwork.com/)
 * [Septeni Original](https://www.septeni-original.co.jp)
-* [SlamData](https://slamdata.com/)
 * [Snowplow Analytics](https://snowplowanalytics.com/)
 * [SoftwareMill](https://softwaremill.com)
 * [Spotify](https://www.spotify.com)
diff --git a/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala b/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala
index deeb34cf..e67fe94a 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala
@@ -120,6 +120,9 @@ object UpdateHeuristic {
   private def removeCommonSuffix(str: String): String =
     util.string.removeSuffix(str, Update.commonSuffixes)
 
+  private def isCommonWord(s: String): Boolean =
+    s === "scala"
+
   val moduleId = UpdateHeuristic(
     name = "moduleId",
     replaceVersion = update =>
@@ -164,14 +167,14 @@ object UpdateHeuristic {
   val relaxed = UpdateHeuristic(
     name = "relaxed",
     replaceVersion = defaultReplaceVersion { update =>
-      util.string.extractWords(update.mainArtifactId)
+      util.string.extractWords(update.mainArtifactId).filterNot(isCommonWord)
     }
   )
 
   val sliding = UpdateHeuristic(
     name = "sliding",
     replaceVersion = defaultReplaceVersion(
-      _.mainArtifactId.toSeq.sliding(5).map(_.unwrap).filterNot(_ === "scala").toList
+      _.mainArtifactId.toSeq.sliding(5).map(_.unwrap).filterNot(isCommonWord).toList
     )
   )
 


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/edit/UpdateHeuristicTest.scala b/modules/core/src/test/scala/org/scalasteward/core/edit/UpdateHeuristicTest.scala
index 054a5d01..a52243e4 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/edit/UpdateHeuristicTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/edit/UpdateHeuristicTest.scala
@@ -469,6 +469,24 @@ class UpdateHeuristicTest extends AnyFunSuite with Matchers {
     Single("be.doeraene" % "scalajs-jquery" % "0.9.3", Nel.of("0.9.4"))
       .replaceVersionIn(original) shouldBe (Some(expected) -> UpdateHeuristic.original.name)
   }
+
+  test("issue 1489: ignore word: scala") {
+    val original =
+      """ val jsoniter = "2.4.0"
+        | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
+        |""".stripMargin
+    val expected =
+      """ val jsoniter = "2.4.1"
+        | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
+        |""".stripMargin
+    Update
+      .Group(
+        "com.github.plokhotnyuk.jsoniter-scala" %
+          Nel.of("jsoniter-scala-core", "jsoniter-scala-macros") % "2.4.0",
+        Nel.of("2.4.1")
+      )
+      .replaceVersionIn(original) shouldBe (Some(expected) -> UpdateHeuristic.relaxed.name)
+  }
 }
 
 object UpdateHeuristicTest {