Skip to content

Commit f067893

Browse files
committed
upgrade Scalafmt (from 1.5.1 to 3.7.4) and reformat sources
1 parent c0ec12b commit f067893

File tree

28 files changed

+446
-359
lines changed

28 files changed

+446
-359
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 = more
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-

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ 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
@@ -37,8 +37,8 @@ package object compat extends compat.PackageShared {
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ object Using {
236236
case _: LinkageError => 3
237237
case _: InterruptedException | _: ThreadDeath => 2
238238
case _: ControlThrowable => 0
239-
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
240-
case _ => -1
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/CompatImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ 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]
2929
var ruined = false
3030

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ class TrulyTraversableLikeExtensionMethods[El1, Repr1](
578578
class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2](
579579
private val self: Tuple2Zipped[El1, Repr1, El2, Repr2]) {
580580

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

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

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import scala.annotation.tailrec
2020
*/
2121
private[scala] object StringParsers {
2222

23-
//compile-time constant helpers
23+
// compile-time constant helpers
2424

25-
//Int.MinValue == -2147483648
25+
// Int.MinValue == -2147483648
2626
private final val intOverflowBoundary = -214748364
2727
private final val intOverflowDigit = 9
28-
//Long.MinValue == -9223372036854775808L
28+
// Long.MinValue == -9223372036854775808L
2929
private final val longOverflowBoundary = -922337203685477580L
3030
private final val longOverflowDigit = 9
3131

@@ -56,23 +56,23 @@ private[scala] object StringParsers {
5656
@inline
5757
private[this] final def isDigit(c: Char): Boolean = c >= '0' && c <= '9'
5858

59-
//bool
59+
// bool
6060
@inline
6161
final def parseBool(from: String): Option[Boolean] =
6262
if (from.equalsIgnoreCase("true")) Some(true)
6363
else if (from.equalsIgnoreCase("false")) Some(false)
6464
else None
6565

66-
//integral types
66+
// integral types
6767
final def parseByte(from: String): Option[Byte] = {
6868
val len = from.length()
69-
//empty strings parse to None
69+
// empty strings parse to None
7070
if (len == 0) None
7171
else {
7272
val first = from.charAt(0)
7373
val v = decValue(first)
7474
if (len == 1) {
75-
//"+" and "-" parse to None
75+
// "+" and "-" parse to None
7676
if (v > -1) Some(v.toByte)
7777
else None
7878
} else if (v > -1) stepToOverflow(from, len, -v, true, Byte.MinValue).map(_.toByte)
@@ -84,13 +84,13 @@ private[scala] object StringParsers {
8484

8585
final def parseShort(from: String): Option[Short] = {
8686
val len = from.length()
87-
//empty strings parse to None
87+
// empty strings parse to None
8888
if (len == 0) None
8989
else {
9090
val first = from.charAt(0)
9191
val v = decValue(first)
9292
if (len == 1) {
93-
//"+" and "-" parse to None
93+
// "+" and "-" parse to None
9494
if (v > -1) Some(v.toShort)
9595
else None
9696
} else if (v > -1) stepToOverflow(from, len, -v, true, Short.MinValue).map(_.toShort)
@@ -116,13 +116,13 @@ private[scala] object StringParsers {
116116
else step(i + 1, (agg * 10) - digit, isPositive)
117117
}
118118
}
119-
//empty strings parse to None
119+
// empty strings parse to None
120120
if (len == 0) None
121121
else {
122122
val first = from.charAt(0)
123123
val v = decValue(first)
124124
if (len == 1) {
125-
//"+" and "-" parse to None
125+
// "+" and "-" parse to None
126126
if (v > -1) Some(v)
127127
else None
128128
} else if (v > -1) step(1, -v, true)
@@ -133,7 +133,7 @@ private[scala] object StringParsers {
133133
}
134134

135135
final def parseLong(from: String): Option[Long] = {
136-
//like parseInt, but Longer
136+
// like parseInt, but Longer
137137
val len = from.length()
138138

139139
@tailrec
@@ -149,13 +149,13 @@ private[scala] object StringParsers {
149149
else step(i + 1, agg * 10 - digit, isPositive)
150150
}
151151
}
152-
//empty strings parse to None
152+
// empty strings parse to None
153153
if (len == 0) None
154154
else {
155155
val first = from.charAt(0)
156156
val v = decValue(first).toLong
157157
if (len == 1) {
158-
//"+" and "-" parse to None
158+
// "+" and "-" parse to None
159159
if (v > -1) Some(v)
160160
else None
161161
} else if (v > -1) step(1, -v, true)
@@ -165,24 +165,24 @@ private[scala] object StringParsers {
165165
}
166166
}
167167

168-
//floating point
168+
// floating point
169169
final def checkFloatFormat(format: String): Boolean = {
170-
//indices are tracked with a start index which points *at* the first index
171-
//and an end index which points *after* the last index
172-
//so that slice length === end - start
173-
//thus start == end <=> empty slice
174-
//and format.substring(start, end) is equivalent to the slice
170+
// indices are tracked with a start index which points *at* the first index
171+
// and an end index which points *after* the last index
172+
// so that slice length === end - start
173+
// thus start == end <=> empty slice
174+
// and format.substring(start, end) is equivalent to the slice
175175

176-
//some utilities for working with index bounds into the original string
176+
// some utilities for working with index bounds into the original string
177177
@inline
178178
def forAllBetween(start: Int, end: Int, pred: Char => Boolean): Boolean = {
179179
@tailrec
180180
def rec(i: Int): Boolean = i >= end || pred(format.charAt(i)) && rec(i + 1)
181181
rec(start)
182182
}
183183

184-
//one after last index for the predicate to hold, or `from` if none hold
185-
//may point after the end of the string
184+
// one after last index for the predicate to hold, or `from` if none hold
185+
// may point after the end of the string
186186
@inline
187187
def skipIndexWhile(predicate: Char => Boolean, from: Int, until: Int): Int = {
188188
@tailrec @inline
@@ -201,20 +201,21 @@ private[scala] object StringParsers {
201201
def prefixOK(startIndex: Int, endIndex: Int): Boolean = {
202202
val len = endIndex - startIndex
203203
(len > 0) && {
204-
//the prefix part is
205-
//hexDigits
206-
//hexDigits.
207-
//hexDigits.hexDigits
208-
//.hexDigits
209-
//but not .
204+
// the prefix part is
205+
// hexDigits
206+
// hexDigits.
207+
// hexDigits.hexDigits
208+
// .hexDigits
209+
// but not .
210210
if (format.charAt(startIndex) == '.') {
211211
(len > 1) && forAllBetween(startIndex + 1, endIndex, isHexDigit)
212212
} else {
213213
val noLeading = skipIndexWhile(isHexDigit, startIndex, endIndex)
214214
(noLeading >= endIndex) ||
215-
((format.charAt(noLeading) == '.') && forAllBetween(noLeading + 1,
216-
endIndex,
217-
isHexDigit))
215+
((format.charAt(noLeading) == '.') && forAllBetween(
216+
noLeading + 1,
217+
endIndex,
218+
isHexDigit))
218219
}
219220
}
220221
}
@@ -234,7 +235,7 @@ private[scala] object StringParsers {
234235
}
235236

236237
def isDecFloatLiteral(startIndex: Int, endIndex: Int): Boolean = {
237-
//invariant: endIndex > startIndex
238+
// invariant: endIndex > startIndex
238239

239240
def isExp(c: Char): Boolean = c == 'e' || c == 'E'
240241

@@ -247,57 +248,59 @@ private[scala] object StringParsers {
247248
else skipIndexWhile(isDigit, startIndex, endIndex) == endIndex
248249
}
249250

250-
//significant can be one of
251-
//* digits.digits
252-
//* .digits
253-
//* digits.
254-
//but not just .
251+
// significant can be one of
252+
// * digits.digits
253+
// * .digits
254+
// * digits.
255+
// but not just .
255256
val startChar = format.charAt(startIndex)
256257
if (startChar == '.') {
257258
val noSignificant = skipIndexWhile(isDigit, startIndex + 1, endIndex)
258259
// a digit is required followed by optional exp
259260
(noSignificant > startIndex + 1) && (noSignificant >= endIndex ||
260-
isExp(format.charAt(noSignificant)) && expOK(noSignificant + 1, endIndex))
261+
isExp(format.charAt(noSignificant)) && expOK(noSignificant + 1, endIndex))
261262
} else if (isDigit(startChar)) {
262263
// one set of digits, then optionally a period, then optionally another set of digits, then optionally an exponent
263264
val noInt = skipIndexWhile(isDigit, startIndex, endIndex)
264265
// just the digits
265266
(noInt == endIndex) || {
266267
if (format.charAt(noInt) == '.') {
267268
val noSignificant = skipIndexWhile(isDigit, noInt + 1, endIndex)
268-
(noSignificant >= endIndex) || //no exponent
269+
(noSignificant >= endIndex) || // no exponent
269270
isExp(format.charAt(noSignificant)) && expOK(noSignificant + 1, endIndex)
270271
} else
271272
isExp(format.charAt(noInt)) && expOK(noInt + 1, endIndex)
272273
}
273274
} else false
274275
}
275276

276-
//count 0x00 to 0x20 as "whitespace", and nothing else
277+
// count 0x00 to 0x20 as "whitespace", and nothing else
277278
val unspacedStart = format.indexWhere(ch => ch.toInt > 0x20)
278279
val unspacedEnd = format.lastIndexWhere(ch => ch.toInt > 0x20) + 1
279280

280281
if (unspacedStart == -1 || unspacedStart >= unspacedEnd || unspacedEnd <= 0) false
281282
else {
282-
//all formats can have a sign
283+
// all formats can have a sign
283284
val unsigned = {
284285
val startchar = format.charAt(unspacedStart)
285286
if (startchar == '-' || startchar == '+') unspacedStart + 1 else unspacedStart
286287
}
287288
if (unsigned >= unspacedEnd) false
288-
//that's it for NaN and Infinity
289+
// that's it for NaN and Infinity
289290
else if (format.charAt(unsigned) == 'N') format.substring(unsigned, unspacedEnd) == "NaN"
290291
else if (format.charAt(unsigned) == 'I') format.substring(unsigned, unspacedEnd) == "Infinity"
291292
else {
292-
//all other formats can have a format suffix
293+
// all other formats can have a format suffix
293294
val desuffixed = {
294295
val endchar = format.charAt(unspacedEnd - 1)
295296
if (endchar == 'f' || endchar == 'F' || endchar == 'd' || endchar == 'D') unspacedEnd - 1
296297
else unspacedEnd
297298
}
298299
val len = desuffixed - unsigned
299300
if (len <= 0) false
300-
else if (len >= 2 && (format.charAt(unsigned + 1) == 'x' || format.charAt(unsigned + 1) == 'X'))
301+
else if (
302+
len >= 2 && (format.charAt(unsigned + 1) == 'x' || format.charAt(unsigned + 1) == 'X')
303+
)
301304
format.charAt(unsigned) == '0' && isHexFloatLiteral(unsigned + 2, desuffixed)
302305
else isDecFloatLiteral(unsigned, desuffixed)
303306
}

0 commit comments

Comments
 (0)