Skip to content

Commit

Permalink
upgrade Scalafmt (from 1.5.1 to 3.7.4) and reformat sources
Browse files Browse the repository at this point in the history
  • Loading branch information
SethTisue committed Jun 14, 2023
1 parent c0ec12b commit f4728ee
Show file tree
Hide file tree
Showing 30 changed files with 466 additions and 377 deletions.
17 changes: 11 additions & 6 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
version=1.5.1
align = more
docstrings = JavaDoc
assumeStandardLibraryStripMargin = true
version = 3.7.4
runner.dialect = scala3
align.preset = more
docstrings.style = keep
rewrite.trailingCommas.style = keep
align.openParenDefnSite = true
newlines.avoidInResultType = true
danglingParentheses.defnSite = false
danglingParentheses.callSite = false
newlines.source = keep
newlines.implicitParamListModifierPrefer = before
project.git = true
maxColumn = 100
project.excludeFilters = [
Expand All @@ -12,5 +19,3 @@ project.excludeFilters = [
"scalafix/output213/"
"scalafix/output213-failure/"
]


4 changes: 2 additions & 2 deletions admin/scalafmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# set -x

HERE="`dirname $0`"
VERSION="1.5.1"
VERSION="3.7.4"
COURSIER="$HERE/.coursier"
SCALAFMT="$HERE/.scalafmt-$VERSION"

Expand All @@ -15,7 +15,7 @@ if [ ! -f $COURSIER ]; then
fi

if [ ! -f $SCALAFMT ]; then
$COURSIER bootstrap com.geirsson:scalafmt-cli_2.11:$VERSION --main org.scalafmt.cli.Cli -o $SCALAFMT
$COURSIER bootstrap org.scalameta:scalafmt-cli_2.12:$VERSION --main org.scalafmt.cli.Cli -o $SCALAFMT
chmod +x $SCALAFMT
fi

Expand Down
34 changes: 18 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(
name := "scala-collection-compat",
name := "scala-collection-compat",
publish / skip := true
)
.aggregate(
Expand Down Expand Up @@ -60,8 +60,8 @@ lazy val compat = new MultiScalaCrossProject(
_.settings(ScalaModulePlugin.scalaModuleSettings)
.settings(commonSettings)
.settings(
name := "scala-collection-compat",
moduleName := "scala-collection-compat",
name := "scala-collection-compat",
moduleName := "scala-collection-compat",
scalaModuleAutomaticModuleName := Some("scala.collection.compat"),
scalacOptions ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions"),
Compile / unmanagedSourceDirectories += {
Expand All @@ -87,7 +87,9 @@ lazy val compat = new MultiScalaCrossProject(
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq(
exclude[ReversedMissingMethodProblem]("scala.collection.compat.PackageShared.*"), // it's package-private
exclude[ReversedMissingMethodProblem](
"scala.collection.compat.PackageShared.*"
), // it's package-private
exclude[Problem]("scala.collection.compat.*PreservingBuilder*")
)
}
Expand Down Expand Up @@ -147,8 +149,8 @@ lazy val compat = new MultiScalaCrossProject(
}
},
versionPolicyIntention := Compatibility.None,
versionCheck := {}, // I don't understand why this fails otherwise?! oh well
Test / fork := false // Scala Native cannot run forked tests
versionCheck := {}, // I don't understand why this fails otherwise?! oh well
Test / fork := false // Scala Native cannot run forked tests
).nativeEnablePlugins(ScalaNativeJUnitPlugin)
)

Expand Down Expand Up @@ -187,7 +189,7 @@ lazy val binaryCompat = project
.in(file("binary-compat/test"))
.settings(commonSettings)
.settings(
scalaVersion := scala212,
scalaVersion := scala212,
libraryDependencies += "com.typesafe" %% "mima-core" % "0.8.0" % Test,
junit,
buildInfoPackage := "build",
Expand All @@ -211,10 +213,10 @@ lazy val scalafixRules = project
.settings(commonSettings)
.settings(
scalaModuleAutomaticModuleName := None,
versionPolicyIntention := Compatibility.None,
versionCheck := {}, // I don't understand why this fails otherwise?! oh well
name := "scala-collection-migrations",
scalaVersion := scalafixScala212,
versionPolicyIntention := Compatibility.None,
versionCheck := {}, // I don't understand why this fails otherwise?! oh well
name := "scala-collection-migrations",
scalaVersion := scalafixScala212,
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % scalafixVersion
)

Expand Down Expand Up @@ -247,9 +249,9 @@ lazy val scalafixInput = project
.settings(commonSettings)
.settings(sharedScalafixSettings)
.settings(
scalaVersion := scalafixScala212,
scalaVersion := scalafixScala212,
publish / skip := true,
headerCheck := Nil,
headerCheck := Nil,
addCompilerPlugin(scalafixSemanticdb),
scalacOptions ++= Seq(
"-Yrangepos",
Expand All @@ -265,7 +267,7 @@ val scalafixOutput = MultiScalaProject(
.settings(commonSettings)
.settings(
publish / skip := true,
headerCheck := Nil,
headerCheck := Nil,
)
.disablePlugins(ScalafixPlugin)
)
Expand Down Expand Up @@ -315,7 +317,7 @@ lazy val scalafixTests = project
.settings(commonSettings)
.settings(sharedScalafixSettings)
.settings(
scalaVersion := scalafixScala212,
scalaVersion := scalafixScala212,
publish / skip := true,
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % scalafixVersion % Test cross CrossVersion.full,
scalafixTestkitOutputSourceDirectories := Seq(
Expand All @@ -325,7 +327,7 @@ lazy val scalafixTests = project
output213.value
),
scalafixTestkitInputSourceDirectories := (scalafixInput / Compile / sourceDirectories).value,
scalafixTestkitInputClasspath := (scalafixInput / Compile / fullClasspath).value,
scalafixTestkitInputClasspath := (scalafixInput / Compile / fullClasspath).value,
)
.dependsOn(scalafixInput, scalafixRules)
.enablePlugins(BuildInfoPlugin, ScalafixTestkitPlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package object compat extends compat.PackageShared {
// the strict type of the view to be `Map` instead of `Iterable`
// Instances produced by this method are used to chain `filterKeys` after `mapValues`
implicit def canBuildFromIterableViewMapLike[K, V, L, W, CC[X, Y] <: Map[X, Y]]
: CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] =
: CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] =
new CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] {
// `CanBuildFrom` parameters are used as type constraints, they are not used
// at run-time, hence the dummy builder implementations
Expand All @@ -37,8 +37,8 @@ package object compat extends compat.PackageShared {
}

implicit def toTraversableLikeExtensionMethods[Repr](self: Repr)(
implicit traversable: IsTraversableLike[Repr])
: TraversableLikeExtensionMethods[traversable.A, Repr] =
implicit
traversable: IsTraversableLike[Repr]): TraversableLikeExtensionMethods[traversable.A, Repr] =
new TraversableLikeExtensionMethods[traversable.A, Repr](traversable.conversion(self))

implicit def toSeqExtensionMethods[A](self: c.Seq[A]): SeqExtensionMethods[A] =
Expand Down
4 changes: 2 additions & 2 deletions compat/src/main/scala-2.11/scala/util/Using.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ object Using {
case _: LinkageError => 3
case _: InterruptedException | _: ThreadDeath => 2
case _: ControlThrowable => 0
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
case _ => -1
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
case _ => -1
}
// special-case `ControlThrowable`, which incorrectly suppresses exceptions
// before 2.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private abstract class PreservingBuilder[A, C <: TraversableOnce[A]] extends m.B
val that: m.Builder[A, C]
val ct: ClassTag[C]

//invariant: ruined => (collection == null)
// invariant: ruined => (collection == null)
var collection: C = null.asInstanceOf[C]
var ruined = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ class TrulyTraversableLikeExtensionMethods[El1, Repr1](
class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2](
private val self: Tuple2Zipped[El1, Repr1, El2, Repr2]) {

def lazyZip[El3, Repr3, T3](t3: T3)(implicit w3: T3 => IterableLike[El3, Repr3])
: Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3] =
def lazyZip[El3, Repr3, T3](t3: T3)(implicit
w3: T3 => IterableLike[El3, Repr3]): Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3] =
new Tuple3Zipped((self.colls._1, self.colls._2, t3))
}

Expand Down
Loading

0 comments on commit f4728ee

Please sign in to comment.