Skip to content

Commit

Permalink
Update scalafmt-core to 2.4.1 (#1329)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 2.4.1

* fmt

Co-authored-by: Frank S. Thomas <f.thomas@gmx.de>
  • Loading branch information
scala-steward and fthomas committed Feb 16, 2020
1 parent 5bde1bd commit 112b76e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
@@ -1,4 +1,4 @@
version = 2.3.2
version = 2.4.1
assumeStandardLibraryStripMargin = true
align.openParenCallSite = false
align.openParenDefnSite = false
Expand Down
Expand Up @@ -118,31 +118,32 @@ object UpdateHeuristic {
val moduleId = UpdateHeuristic(
name = "moduleId",
replaceVersion = update =>
target => {
val groupId = Regex.quote(update.groupId.value)
val artifactIds =
alternation(update.artifactIds.map(artifactId => Regex.quote(artifactId.name)))
val currentVersion = Regex.quote(update.currentVersion)
val regex =
raw"""(.*)(["|`]$groupId(?:"\s*%+\s*"|:+)$artifactIds(?:"\s*%\s*|:+))("?)($currentVersion)("|`)""".r
replaceSomeInAllowedParts(
regex,
target,
match0 => {
val precedingCharacters = match0.group(1)
val dependency = match0.group(2)
val versionPrefix = match0.group(4)
val versionSuffix = match0.group(6)
if (shouldBeIgnored(precedingCharacters)) None
else
Some(
Regex.quoteReplacement(
s"""$precedingCharacters$dependency$versionPrefix${update.nextVersion}$versionSuffix"""
target =>
{
val groupId = Regex.quote(update.groupId.value)
val artifactIds =
alternation(update.artifactIds.map(artifactId => Regex.quote(artifactId.name)))
val currentVersion = Regex.quote(update.currentVersion)
val regex =
raw"""(.*)(["|`]$groupId(?:"\s*%+\s*"|:+)$artifactIds(?:"\s*%\s*|:+))("?)($currentVersion)("|`)""".r
replaceSomeInAllowedParts(
regex,
target,
match0 => {
val precedingCharacters = match0.group(1)
val dependency = match0.group(2)
val versionPrefix = match0.group(4)
val versionSuffix = match0.group(6)
if (shouldBeIgnored(precedingCharacters)) None
else
Some(
Regex.quoteReplacement(
s"""$precedingCharacters$dependency$versionPrefix${update.nextVersion}$versionSuffix"""
)
)
)
}
).someIfChanged
} >>= replaceGroupF(update)
}
).someIfChanged
} >>= replaceGroupF(update)
)

val strict = UpdateHeuristic(
Expand Down
Expand Up @@ -112,9 +112,7 @@ object FileAlg {
val copyOptions = File.CopyOptions(overwrite = true)
if (file.exists) Some(file.moveTo(File.newTemporaryFile())(copyOptions)) else None
}
} { _ =>
fa
} {
}(_ => fa) {
case Some(tmpFile) => F.delay(tmpFile.moveTo(file)).void
case None => F.unit
}
Expand Down
Expand Up @@ -81,7 +81,7 @@ final class NurtureAlg[F[_]](
for {
repoConfig <- repoConfigAlg.readRepoConfigOrDefault(repo)
grouped = Update.groupByGroupId(updates)
sorted = grouped.sortBy { migrationAlg.findMigrations(_).size }
sorted = grouped.sortBy(migrationAlg.findMigrations(_).size)
_ <- logger.info(util.logger.showUpdates(sorted))
baseSha1 <- gitAlg.latestSha1(repo, baseBranch)
_ <- NurtureAlg.processUpdates(
Expand Down
Expand Up @@ -70,7 +70,7 @@ object string {
replacer: Regex.Match => Option[String]
): Change[String] = {
var changed = false
val replacer1 = replacer.andThen(_.map(r => { changed = true; r }))
val replacer1 = replacer.andThen(_.map { r => changed = true; r })
val result = regex.replaceSomeIn(target, replacer1)
if (changed) Changed(result) else Unchanged(result)
}
Expand Down
Expand Up @@ -187,9 +187,7 @@ class VersionTest
}

test("Component: round-trip") {
forAll { str: String =>
Component.render(Component.parse(str)) shouldBe str
}
forAll { str: String => Component.render(Component.parse(str)) shouldBe str }
}

test("Component: round-trip example") {
Expand Down
Expand Up @@ -25,7 +25,8 @@ class UpdateAlgTest extends AnyFunSuite with Matchers {
}

test("findUpdate: newer groupId") {
val dependency = "org.spire-math" % ArtifactId("kind-projector", "kind-projector_2.12") % "0.9.10"
val dependency =
"org.spire-math" % ArtifactId("kind-projector", "kind-projector_2.12") % "0.9.10"
val expected = Update.Single(
"org.spire-math" % ArtifactId("kind-projector", "kind-projector_2.12") % "0.9.10",
Nel.of("0.10.0"),
Expand Down
3 changes: 2 additions & 1 deletion project/Dependencies.scala
Expand Up @@ -28,7 +28,8 @@ object Dependencies {
val refinedCats = "eu.timepit" %% "refined-cats" % refined.revision
val refinedScalacheck = "eu.timepit" %% "refined-scalacheck" % refined.revision
val scalacacheCaffeine = "com.github.cb372" %% "scalacache-caffeine" % "0.28.0"
val scalacacheCatsEffect = "com.github.cb372" %% "scalacache-cats-effect" % scalacacheCaffeine.revision
val scalacacheCatsEffect =
"com.github.cb372" %% "scalacache-cats-effect" % scalacacheCaffeine.revision
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.3"
val scalaTest = "org.scalatest" %% "scalatest" % "3.1.0"
}

0 comments on commit 112b76e

Please sign in to comment.