Skip to content

Commit cb11b0d

Browse files
authored
Merge pull request #604 from SethTisue/scalafmt-upgrade
2 parents 0add397 + a8fe103 commit cb11b0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+822
-733
lines changed

.scalafmt.conf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
version=1.5.1
2-
align = more
3-
docstrings = JavaDoc
4-
assumeStandardLibraryStripMargin = true
1+
version = 3.7.4
2+
runner.dialect = scala3
3+
align.preset = none
4+
docstrings.style = keep
5+
rewrite.trailingCommas.style = keep
6+
align.openParenDefnSite = true
7+
newlines.avoidInResultType = true
8+
danglingParentheses.defnSite = false
9+
danglingParentheses.callSite = false
10+
newlines.source = keep
11+
newlines.implicitParamListModifierPrefer = before
512
project.git = true
613
maxColumn = 100
714
project.excludeFilters = [
@@ -12,5 +19,3 @@ project.excludeFilters = [
1219
"scalafix/output213/"
1320
"scalafix/output213-failure/"
1421
]
15-
16-

admin/scalafmt.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# set -x
44

55
HERE="`dirname $0`"
6-
VERSION="1.5.1"
6+
VERSION="3.7.4"
77
COURSIER="$HERE/.coursier"
88
SCALAFMT="$HERE/.scalafmt-$VERSION"
99

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

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

binary-compat/test/src/test/scala/BinaryCompaTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.typesafe.tools.mima.lib.MiMaLib
2121
class BinaryCompaTest {
2222
@Test
2323
def compat(): Unit = {
24-
val mima = new MiMaLib(Seq())
24+
val mima = new MiMaLib(Seq())
2525
val allProblems = mima.collectProblems(new File(oldClasses), new File(newClasses))
2626
val unexpectedDescriptions =
2727
allProblems.iterator

build.sbt

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ lazy val junit = libraryDependencies += "com.github.sbt" % "junit-interface" % "
5353
lazy val scala211 = "2.11.12"
5454
lazy val scala212 = "2.12.17"
5555
lazy val scala213 = "2.13.11"
56-
lazy val scala3 = "3.2.2"
56+
lazy val scala3 = "3.2.2"
5757

5858
lazy val compat = new MultiScalaCrossProject(
5959
"compat",
@@ -87,7 +87,9 @@ lazy val compat = new MultiScalaCrossProject(
8787
import com.typesafe.tools.mima.core._
8888
import com.typesafe.tools.mima.core.ProblemFilters._
8989
Seq(
90-
exclude[ReversedMissingMethodProblem]("scala.collection.compat.PackageShared.*"), // it's package-private
90+
exclude[ReversedMissingMethodProblem](
91+
"scala.collection.compat.PackageShared.*"
92+
), // it's package-private
9193
exclude[Problem]("scala.collection.compat.*PreservingBuilder*")
9294
)
9395
}
@@ -115,7 +117,7 @@ lazy val compat = new MultiScalaCrossProject(
115117
.head
116118
val opt = CrossVersion.partialVersion(scalaVersion.value) match {
117119
case Some((3, _)) => "-scalajs-mapSourceURI"
118-
case _ => "-P:scalajs:mapSourceURI"
120+
case _ => "-P:scalajs:mapSourceURI"
119121
}
120122
Seq(s"$opt:$x->$y/")
121123
},
@@ -135,7 +137,7 @@ lazy val compat = new MultiScalaCrossProject(
135137
nativeLinkStubs := true,
136138
mimaPreviousArtifacts := (CrossVersion.partialVersion(scalaVersion.value) match {
137139
case Some((3, 1)) => mimaPreviousArtifacts.value.filter(_.revision != "2.6.0")
138-
case _ => mimaPreviousArtifacts.value
140+
case _ => mimaPreviousArtifacts.value
139141
}),
140142
Compile / unmanagedSourceDirectories += {
141143
val jsAndNativeSourcesParent = (ThisBuild / baseDirectory).value / "compat/jsNative/src/main"
@@ -155,20 +157,20 @@ lazy val compat = new MultiScalaCrossProject(
155157
val compat211 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala211)
156158
val compat212 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala212)
157159
val compat213 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala213)
158-
val compat3 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala3)
160+
val compat3 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala3)
159161

160-
lazy val compat211JVM = compat211.jvm
161-
lazy val compat211JS = compat211.js
162+
lazy val compat211JVM = compat211.jvm
163+
lazy val compat211JS = compat211.js
162164
lazy val compat211Native = compat211.native
163-
lazy val compat212JVM = compat212.jvm
164-
lazy val compat212JS = compat212.js
165+
lazy val compat212JVM = compat212.jvm
166+
lazy val compat212JS = compat212.js
165167
lazy val compat212Native = compat212.native
166-
lazy val compat213JVM = compat213.jvm
167-
lazy val compat213JS = compat213.js
168+
lazy val compat213JVM = compat213.jvm
169+
lazy val compat213JS = compat213.js
168170
lazy val compat213Native = compat213.native
169-
lazy val compat3JVM = compat3.jvm
170-
lazy val compat3JS = compat3.js
171-
lazy val compat3Native = compat3.native
171+
lazy val compat3JVM = compat3.jvm
172+
lazy val compat3JS = compat3.js
173+
lazy val compat3Native = compat3.native
172174

173175
lazy val binaryCompatOld = project
174176
.in(file("binary-compat/old"))
@@ -331,12 +333,12 @@ lazy val scalafixTests = project
331333
.enablePlugins(BuildInfoPlugin, ScalafixTestkitPlugin)
332334

333335
val ciScalaVersion = sys.env.get("CI_SCALA_VERSION").flatMap(Version.parse)
334-
val ciPlatform = sys.env.get("CI_PLATFORM").map(p => if (p == "JVM") "" else p)
335-
val isScalafix = sys.env.get("CI_MODE") == Some("testScalafix")
336-
val isScalafmt = sys.env.get("CI_MODE") == Some("testScalafmt")
336+
val ciPlatform = sys.env.get("CI_PLATFORM").map(p => if (p == "JVM") "" else p)
337+
val isScalafix = sys.env.get("CI_MODE") == Some("testScalafix")
338+
val isScalafmt = sys.env.get("CI_MODE") == Some("testScalafmt")
337339
val isBinaryCompat = sys.env.get("CI_MODE") == Some("testBinaryCompat")
338-
val isHeaderCheck = sys.env.get("CI_MODE") == Some("headerCheck")
339-
val jdkVersion = sys.env.get("CI_JDK").map(_.toInt)
340+
val isHeaderCheck = sys.env.get("CI_MODE") == Some("headerCheck")
341+
val jdkVersion = sys.env.get("CI_JDK").map(_.toInt)
340342

341343
// required by sbt-scala-module
342344
inThisBuild {
@@ -365,7 +367,7 @@ inThisBuild {
365367
).foreach(k =>
366368
println(k.padTo(20, " ").mkString("") + " -> " + sys.env.getOrElse(k, "None")))
367369

368-
val compatProject = s"compat${ciScalaVersion.get}${ciPlatform.get}"
370+
val compatProject = s"compat${ciScalaVersion.get}${ciPlatform.get}"
369371
val binaryCompatProject = "binaryCompat"
370372

371373
val testProjectPrefix =

compat/jvm/src/main/scala-2.11_2.12/scala/jdk/OptionShape.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object OptionShape {
4141

4242
def fromScala(o: Option[Double]): OptionalDouble = o match {
4343
case Some(d) => OptionalDouble.of(d)
44-
case _ => OptionalDouble.empty
44+
case _ => OptionalDouble.empty
4545
}
4646
}
4747
implicit val jDoubleOptionShape: OptionShape[jl.Double, OptionalDouble] =
@@ -53,7 +53,7 @@ object OptionShape {
5353

5454
def fromScala(o: Option[Int]): OptionalInt = o match {
5555
case Some(d) => OptionalInt.of(d)
56-
case _ => OptionalInt.empty
56+
case _ => OptionalInt.empty
5757
}
5858
}
5959
implicit val jIntegerOptionShape: OptionShape[jl.Integer, OptionalInt] =
@@ -66,7 +66,7 @@ object OptionShape {
6666

6767
def fromScala(o: Option[Long]): OptionalLong = o match {
6868
case Some(d) => OptionalLong.of(d)
69-
case _ => OptionalLong.empty
69+
case _ => OptionalLong.empty
7070
}
7171
}
7272
implicit val jLongOptionShape: OptionShape[jl.Long, OptionalLong] =

compat/src/main/scala-2.11/scala/collection/compat/package.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ package object compat extends compat.PackageShared {
2828
// the strict type of the view to be `Map` instead of `Iterable`
2929
// Instances produced by this method are used to chain `filterKeys` after `mapValues`
3030
implicit def canBuildFromIterableViewMapLike[K, V, L, W, CC[X, Y] <: Map[X, Y]]
31-
: CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] =
31+
: CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] =
3232
new CanBuildFrom[IterableView[(K, V), CC[K, V]], (L, W), IterableView[(L, W), CC[L, W]]] {
3333
// `CanBuildFrom` parameters are used as type constraints, they are not used
3434
// at run-time, hence the dummy builder implementations
3535
def apply(from: IterableView[(K, V), CC[K, V]]) = new TraversableView.NoBuilder
36-
def apply() = new TraversableView.NoBuilder
36+
def apply() = new TraversableView.NoBuilder
3737
}
3838

3939
implicit def toTraversableLikeExtensionMethods[Repr](self: Repr)(
40-
implicit traversable: IsTraversableLike[Repr])
41-
: TraversableLikeExtensionMethods[traversable.A, Repr] =
40+
implicit
41+
traversable: IsTraversableLike[Repr]): TraversableLikeExtensionMethods[traversable.A, Repr] =
4242
new TraversableLikeExtensionMethods[traversable.A, Repr](traversable.conversion(self))
4343

4444
implicit def toSeqExtensionMethods[A](self: c.Seq[A]): SeqExtensionMethods[A] =

compat/src/main/scala-2.11/scala/util/Using.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ object Using {
145145
final class Manager private {
146146
import Manager._
147147

148-
private var closed = false
148+
private var closed = false
149149
private[this] var resources: List[Resource[_]] = Nil
150150

151151
/** Registers the specified resource with this manager, so that
@@ -232,12 +232,12 @@ object Using {
232232

233233
private def preferentiallySuppress(primary: Throwable, secondary: Throwable): Throwable = {
234234
def score(t: Throwable): Int = t match {
235-
case _: VirtualMachineError => 4
236-
case _: LinkageError => 3
235+
case _: VirtualMachineError => 4
236+
case _: LinkageError => 3
237237
case _: InterruptedException | _: ThreadDeath => 2
238-
case _: ControlThrowable => 0
239-
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
240-
case _ => -1
238+
case _: ControlThrowable => 0
239+
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
240+
case _ => -1
241241
}
242242
// special-case `ControlThrowable`, which incorrectly suppresses exceptions
243243
// before 2.13

compat/src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object BuildFrom {
4040
implicit cbf: CanBuildFrom[From, A, C]): BuildFrom[From, A, C] =
4141
new BuildFrom[From, A, C] {
4242
def fromSpecific(from: From)(it: IterableOnce[A]): C = (cbf(from) ++= it).result()
43-
def newBuilder(from: From): mutable.Builder[A, C] = cbf(from)
43+
def newBuilder(from: From): mutable.Builder[A, C] = cbf(from)
4444
}
4545

4646
// Implicit conversion derived from an implicit conversion to CanBuildFrom

compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ private abstract class PreservingBuilder[A, C <: TraversableOnce[A]] extends m.B
2424
val that: m.Builder[A, C]
2525
val ct: ClassTag[C]
2626

27-
//invariant: ruined => (collection == null)
27+
// invariant: ruined => (collection == null)
2828
var collection: C = null.asInstanceOf[C]
29-
var ruined = false
29+
var ruined = false
3030

3131
private[this] def ruin(): Unit = {
3232
if (collection != null) that ++= collection
@@ -80,9 +80,9 @@ private[compat] object CompatImpl {
8080
def simpleCBF[A, C](f: => m.Builder[A, C]): CanBuildFrom[Any, A, C] =
8181
new CanBuildFrom[Any, A, C] {
8282
def apply(from: Any): m.Builder[A, C] = apply()
83-
def apply(): m.Builder[A, C] = f
83+
def apply(): m.Builder[A, C] = f
8484
}
8585

8686
type ImmutableBitSetCC[X] = ({ type L[_] = i.BitSet })#L[X]
87-
type MutableBitSetCC[X] = ({ type L[_] = m.BitSet })#L[X]
87+
type MutableBitSetCC[X] = ({ type L[_] = m.BitSet })#L[X]
8888
}

compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ class StreamExtensionMethods[A](private val stream: Stream[A]) extends AnyVal {
396396
}
397397

398398
class SortedExtensionMethods[K, T <: Sorted[K, T]](private val fact: Sorted[K, T]) {
399-
def rangeFrom(from: K): T = fact.from(from)
400-
def rangeTo(to: K): T = fact.to(to)
399+
def rangeFrom(from: K): T = fact.from(from)
400+
def rangeTo(to: K): T = fact.to(to)
401401
def rangeUntil(until: K): T = fact.until(until)
402402
}
403403

@@ -409,7 +409,7 @@ class IteratorExtensionMethods[A](private val self: c.Iterator[A]) extends AnyVa
409409
if (self.hasNext) Some(self.next()) else None
410410
}
411411
def concat[B >: A](that: c.TraversableOnce[B]): c.TraversableOnce[B] = self ++ that
412-
def tapEach[U](f: A => U): c.Iterator[A] = self.map(a => { f(a); a })
412+
def tapEach[U](f: A => U): c.Iterator[A] = self.map(a => { f(a); a })
413413
}
414414

415415
class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A]) extends AnyVal {
@@ -447,8 +447,8 @@ class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A])
447447
class TraversableExtensionMethods[A](private val self: c.Traversable[A]) extends AnyVal {
448448
def iterableFactory: GenericCompanion[Traversable] = self.companion
449449

450-
def sizeCompare(otherSize: Int): Int = SizeCompareImpl.sizeCompareInt(self)(otherSize)
451-
def sizeIs: SizeCompareOps = new SizeCompareOps(self)
450+
def sizeCompare(otherSize: Int): Int = SizeCompareImpl.sizeCompareInt(self)(otherSize)
451+
def sizeIs: SizeCompareOps = new SizeCompareOps(self)
452452
def sizeCompare(that: c.Traversable[_]): Int = SizeCompareImpl.sizeCompareColl(self)(that)
453453

454454
}
@@ -486,7 +486,7 @@ private object SizeCompareImpl {
486486
case _ =>
487487
if (otherSize < 0) 1
488488
else {
489-
var i = 0
489+
var i = 0
490490
val it = self.toIterator
491491
while (it.hasNext) {
492492
if (i == otherSize) return 1
@@ -532,7 +532,7 @@ class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversabl
532532
val r = bf2()
533533
self.foreach { x =>
534534
f(x) match {
535-
case Left(x1) => l += x1
535+
case Left(x1) => l += x1
536536
case Right(x2) => r += x2
537537
}
538538
}
@@ -543,7 +543,7 @@ class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversabl
543543
implicit bf: CanBuildFrom[Repr, B, That]): Map[K, That] = {
544544
val map = m.Map.empty[K, m.Builder[B, That]]
545545
for (elem <- self) {
546-
val k = key(elem)
546+
val k = key(elem)
547547
val bldr = map.getOrElseUpdate(k, bf(self.repr))
548548
bldr += f(elem)
549549
}
@@ -558,7 +558,7 @@ class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversabl
558558
val k = key(elem)
559559
val v = map.get(k) match {
560560
case Some(b) => reduce(b, f(elem))
561-
case None => f(elem)
561+
case None => f(elem)
562562
}
563563
map.put(k, v)
564564
}
@@ -567,7 +567,7 @@ class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversabl
567567

568568
def distinctBy[B, That](f: A => B)(implicit cbf: CanBuildFrom[Repr, A, That]): That = {
569569
val builder = cbf()
570-
val keys = collection.mutable.Set.empty[B]
570+
val keys = collection.mutable.Set.empty[B]
571571
for (element <- self) {
572572
val key = f(element)
573573
if (!keys.contains(key)) {
@@ -591,8 +591,8 @@ class TrulyTraversableLikeExtensionMethods[El1, Repr1](
591591
class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2](
592592
private val self: Tuple2Zipped[El1, Repr1, El2, Repr2]) {
593593

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

@@ -610,7 +610,7 @@ class ImmutableMapExtensionMethods[K, V](private val self: scala.collection.immu
610610
def updatedWith[V1 >: V](key: K)(remappingFunction: (Option[V]) => Option[V1]): Map[K, V1] =
611611
remappingFunction(self.get(key)) match {
612612
case Some(v) => self.updated(key, v)
613-
case None => self - key
613+
case None => self - key
614614
}
615615
}
616616

@@ -621,7 +621,7 @@ class MutableMapExtensionMethods[K, V](private val self: scala.collection.mutabl
621621
val updatedEntry = remappingFunction(self.get(key))
622622
updatedEntry match {
623623
case Some(v) => self.update(key, v)
624-
case None => self.remove(key)
624+
case None => self.remove(key)
625625
}
626626
updatedEntry
627627
}

0 commit comments

Comments
 (0)