Skip to content

Commit da3a00c

Browse files
authored
Merge pull request #1161 from fthomas/topic/move-removeCommonSuffix
Move Update.removeCommonSuffix to UpdateHeuristic
2 parents 73f6738 + 8dc16ce commit da3a00c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

modules/core/src/main/scala/org/scalasteward/core/data/Update.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ object Update {
101101
val commonSuffixes: List[String] =
102102
List("config", "contrib", "core", "extra", "server")
103103

104-
def removeCommonSuffix(str: String): String =
105-
util.string.removeSuffix(str, commonSuffixes)
106-
107104
def nameOf(groupId: GroupId, artifactId: String): String =
108105
if (commonSuffixes.contains(artifactId))
109106
util.string.rightmostLabel(groupId.value)

modules/core/src/main/scala/org/scalasteward/core/edit/UpdateHeuristic.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ object UpdateHeuristic {
7474
}
7575

7676
def mkRegex(update: Update): Option[Regex] =
77-
searchTermsToAlternation(getSearchTerms(update).map(Update.removeCommonSuffix)).map {
78-
searchTerms =>
79-
val prefix = getPrefixRegex(update).getOrElse("")
80-
val currentVersion = Regex.quote(update.currentVersion)
81-
s"(?i)(.*)($prefix$searchTerms.*?)$currentVersion(.?)".r
77+
searchTermsToAlternation(getSearchTerms(update).map(removeCommonSuffix)).map { searchTerms =>
78+
val prefix = getPrefixRegex(update).getOrElse("")
79+
val currentVersion = Regex.quote(update.currentVersion)
80+
s"(?i)(.*)($prefix$searchTerms.*?)$currentVersion(.?)".r
8281
}
8382

8483
def replaceF(update: Update): String => Option[String] =
@@ -112,6 +111,9 @@ object UpdateHeuristic {
112111
terms.map(Update.nameOf(update.groupId, _)).toList
113112
}
114113

114+
private def removeCommonSuffix(str: String): String =
115+
util.string.removeSuffix(str, Update.commonSuffixes)
116+
115117
val moduleId = UpdateHeuristic(
116118
name = "moduleId",
117119
replaceVersion = update =>

0 commit comments

Comments
 (0)