Skip to content

Commit ed4d6a4

Browse files
committed
Apply scalafmt project-wide
1 parent 576a671 commit ed4d6a4

141 files changed

Lines changed: 4260 additions & 4060 deletions

File tree

Some content is hidden

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

.scalafmt.conf

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
version = 3.8.6
1+
version = 3.11.1
22
runner.dialect = scala213
33

4-
newlines.beforeMultilineDef = keep
5-
newlines.topLevelStatements = [before]
6-
newlines.beforeCurlyLambdaParams = multilineWithCaseOnly
7-
newlines.afterCurlyLambdaParams = squash
8-
newlines.implicitParamListModifierForce = [after]
9-
newlines.avoidForSimpleOverflow = [tooLong]
10-
newlines.avoidInResultType = true
11-
newlines.sometimesBeforeColonInMethodReturnType = false
12-
newlines.beforeTypeBounds = keep
4+
align.openParenCallSite = true
5+
align.openParenDefnSite = true
136

14-
verticalMultiline.atDefnSite = true
15-
verticalMultiline.arityThreshold = 10
7+
maxColumn = 150
8+
continuationIndent.defnSite = 2
169

17-
spaces.inImportCurlyBraces = true
10+
assumeStandardLibraryStripMargin = true
11+
danglingParentheses.preset = true
12+
13+
rewrite.rules = [SortImports, RedundantParens, SortModifiers]
14+
15+
newlines.source = keep
16+
17+
spaces.inImportCurlyBraces = false
1818

1919
includeCurlyBraceInSelectChains = false
2020
includeNoParensInSelectChains = false
2121
optIn.breakChainOnFirstMethodDot = false
2222

23-
docstrings.style = Asterisk
23+
docstrings.style = keep
2424
docstrings.wrap = no
25+
docstrings.oneline = keep
26+
docstrings.blankFirstLine = keep
27+
28+
literals.long = Upper
29+
literals.float = Upper
30+
literals.double = Upper
2531

26-
literals.long=Upper
27-
literals.float=Upper
28-
literals.double=Upper
32+
docstrings = JavaDoc
33+
newlines.afterCurlyLambda = preserve
34+
docstrings.style = Asterisk
35+
docstrings.oneline = unfold

build.sbt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ lazy val docs = project
204204
.dependsOn(dataset, cats, ml)
205205

206206
def sparkDependencies(
207-
sparkVersion: String,
208-
scope: Configuration = Provided
209-
) = Seq(
207+
sparkVersion: String,
208+
scope: Configuration = Provided
209+
) = Seq(
210210
libraryDependencies ++= Seq(
211211
"org.apache.spark" %% "spark-core" % sparkVersion % scope,
212212
"org.apache.spark" %% "spark-sql" % sparkVersion % scope
@@ -357,11 +357,9 @@ lazy val framelessSettings = Seq(
357357
/**
358358
* The old Scala XML is pulled from Scala 2.12.x.
359359
*
360-
* [error] (update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
361-
* [error]
362-
* [error] * org.scala-lang.modules:scala-xml_2.12:2.3.0 (early-semver) is selected over 1.0.6
363-
* [error] +- org.scoverage:scalac-scoverage-reporter_2.12:2.0.7 (depends on 2.4.0)
364-
* [error] +- org.scala-lang:scala-compiler:2.12.16 (depends on 1.0.6)
360+
* [error] (update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] [error] *
361+
* org.scala-lang.modules:scala-xml_2.12:2.3.0 (early-semver) is selected over 1.0.6 [error] +- org.scoverage:scalac-scoverage-reporter_2.12:2.0.7
362+
* (depends on 2.4.0) [error] +- org.scala-lang:scala-compiler:2.12.16 (depends on 1.0.6)
365363
*/
366364
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
367365
) ++ consoleSettings
@@ -378,10 +376,11 @@ lazy val spark40Settings = Seq[Setting[_]](
378376
lazy val spark34Settings = Seq[Setting[_]](
379377
tlVersionIntroduced := Map("2.12" -> "0.14.1", "2.13" -> "0.14.1"),
380378
mimaPreviousArtifacts := Set(
381-
organization.value %% moduleName.value
382-
.split("-")
383-
.dropRight(1)
384-
.mkString("-") % "0.14.1"
379+
organization.value %%
380+
moduleName.value
381+
.split("-")
382+
.dropRight(1)
383+
.mkString("-") % "0.14.1"
385384
)
386385
)
387386

cats/src/main/scala/frameless/cats/FramelessSyntax.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ trait FramelessSyntax extends frameless.FramelessSyntax {
1313
def withLocalProperty(key: String, value: String): F[A] =
1414
for {
1515
session <- ask
16-
_ <- delay(session.sparkContext.setLocalProperty(key, value))
17-
a <- fa
16+
_ <- delay(session.sparkContext.setLocalProperty(key, value))
17+
a <- fa
1818
} yield a
1919

2020
def withGroupId(groupId: String): F[A] = withLocalProperty("spark.jobGroup.id", groupId)

cats/src/main/scala/frameless/cats/implicits.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ object outer {
6666
def combine(lhs: RDD[(K, V)], rhs: RDD[(K, V)]): RDD[(K, V)] =
6767
lhs.fullOuterJoin(rhs).mapValues {
6868
case (Some(x), Some(y)) => x |+| y
69-
case (None, Some(y)) => y
70-
case (Some(x), None) => x
71-
case (None, None) => m.empty
69+
case (None, Some(y)) => y
70+
case (Some(x), None) => x
71+
case (None, None) => m.empty
7272
}
7373
}
7474
}

cats/src/test/scala/frameless/cats/test.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import org.scalatest.matchers.should.Matchers
2121
import org.scalatest.propspec.AnyPropSpec
2222

2323
trait SparkTests {
24-
val appID: String = new java.util.Date().toString + math.floor(math.random() * 10E4).toLong.toString
24+
val appID: String = new java.util.Date().toString + math.floor(math.random() * 10e4).toLong.toString
2525

2626
val conf: SparkConf = new SparkConf()
2727
.setMaster("local[*]")
@@ -68,7 +68,7 @@ class Test extends AnyPropSpec with Matchers with ScalaCheckPropertyChecks with
6868
PropertyCheckConfiguration(minSize = PosInt(10))
6969

7070
property("spark is working") {
71-
sc.parallelize(Seq(1, 2, 3)).collect() shouldBe Array(1,2,3)
71+
sc.parallelize(Seq(1, 2, 3)).collect() shouldBe Array(1, 2, 3)
7272
}
7373

7474
property("inner pairwise monoid") {
@@ -120,10 +120,10 @@ class Test extends AnyPropSpec with Matchers with ScalaCheckPropertyChecks with
120120

121121
property("pair rdd numeric commutative semigroup example") {
122122
import frameless.cats.implicits._
123-
val seq = Seq( ("a",2), ("b",3), ("d",6), ("b",2), ("d",1) )
123+
val seq = Seq(("a", 2), ("b", 3), ("d", 6), ("b", 2), ("d", 1))
124124
val rdd = seq.toRdd
125-
rdd.cminByKey.collect().toSeq should contain theSameElementsAs Seq( ("a",2), ("b",2), ("d",1) )
126-
rdd.cmaxByKey.collect().toSeq should contain theSameElementsAs Seq( ("a",2), ("b",3), ("d",6) )
127-
rdd.csumByKey.collect().toSeq should contain theSameElementsAs Seq( ("a",2), ("b",5), ("d",7) )
125+
rdd.cminByKey.collect().toSeq should contain theSameElementsAs Seq(("a", 2), ("b", 2), ("d", 1))
126+
rdd.cmaxByKey.collect().toSeq should contain theSameElementsAs Seq(("a", 2), ("b", 3), ("d", 6))
127+
rdd.csumByKey.collect().toSeq should contain theSameElementsAs Seq(("a", 2), ("b", 5), ("d", 7))
128128
}
129129
}

core/src/main/scala/frameless/CatalystAverageable.scala

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package frameless
33
import scala.annotation.implicitNotFound
44

55
/**
6-
* When averaging Spark doesn't change these types:
7-
* - BigDecimal -> BigDecimal
8-
* - Double -> Double
9-
* But it changes these types :
10-
* - Int -> Double
11-
* - Short -> Double
12-
* - Long -> Double
13-
*/
6+
* When averaging Spark doesn't change these types:
7+
* - BigDecimal -> BigDecimal
8+
* - Double -> Double But it changes these types :
9+
* - Int -> Double
10+
* - Short -> Double
11+
* - Long -> Double
12+
*/
1413
@implicitNotFound("Cannot compute average of type ${In}.")
1514
trait CatalystAverageable[In, Out]
1615

@@ -19,8 +18,8 @@ object CatalystAverageable {
1918
private[this] def of[In, Out]: CatalystAverageable[In, Out] = theInstance.asInstanceOf[CatalystAverageable[In, Out]]
2019

2120
implicit val framelessAverageableBigDecimal: CatalystAverageable[BigDecimal, BigDecimal] = of[BigDecimal, BigDecimal]
22-
implicit val framelessAverageableDouble: CatalystAverageable[Double, Double] = of[Double, Double]
23-
implicit val framelessAverageableLong: CatalystAverageable[Long, Double] = of[Long, Double]
24-
implicit val framelessAverageableInt: CatalystAverageable[Int, Double] = of[Int, Double]
25-
implicit val framelessAverageableShort: CatalystAverageable[Short, Double] = of[Short, Double]
21+
implicit val framelessAverageableDouble: CatalystAverageable[Double, Double] = of[Double, Double]
22+
implicit val framelessAverageableLong: CatalystAverageable[Long, Double] = of[Long, Double]
23+
implicit val framelessAverageableInt: CatalystAverageable[Int, Double] = of[Int, Double]
24+
implicit val framelessAverageableShort: CatalystAverageable[Short, Double] = of[Short, Double]
2625
}

core/src/main/scala/frameless/CatalystBitShift.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package frameless
22

33
import scala.annotation.implicitNotFound
44

5-
/** Spark does not return always Int on shift
6-
*/
5+
/**
6+
* Spark does not return always Int on shift
7+
*/
78

89
@implicitNotFound("Cannot do bit shift operations on columns of type ${In}.")
910
trait CatalystBitShift[In, Out]
@@ -12,9 +13,9 @@ object CatalystBitShift {
1213
private[this] val theInstance = new CatalystBitShift[Any, Any] {}
1314
private[this] def of[In, Out]: CatalystBitShift[In, Out] = theInstance.asInstanceOf[CatalystBitShift[In, Out]]
1415

15-
implicit val framelessBitShiftBigDecimal: CatalystBitShift[BigDecimal, Int] = of[BigDecimal, Int]
16-
implicit val framelessBitShiftDouble : CatalystBitShift[Byte, Int] = of[Byte, Int]
17-
implicit val framelessBitShiftInt : CatalystBitShift[Short, Int] = of[Short, Int]
18-
implicit val framelessBitShiftLong : CatalystBitShift[Int, Int] = of[Int, Int]
19-
implicit val framelessBitShiftShort : CatalystBitShift[Long, Long] = of[Long, Long]
16+
implicit val framelessBitShiftBigDecimal: CatalystBitShift[BigDecimal, Int] = of[BigDecimal, Int]
17+
implicit val framelessBitShiftDouble: CatalystBitShift[Byte, Int] = of[Byte, Int]
18+
implicit val framelessBitShiftInt: CatalystBitShift[Short, Int] = of[Short, Int]
19+
implicit val framelessBitShiftLong: CatalystBitShift[Int, Int] = of[Int, Int]
20+
implicit val framelessBitShiftShort: CatalystBitShift[Long, Long] = of[Long, Long]
2021
}

core/src/main/scala/frameless/CatalystBitwise.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package frameless
33
import scala.annotation.implicitNotFound
44

55
/**
6-
* Types that can be bitwise ORed, ANDed, or XORed by Catalyst.
7-
* Note that Catalyst requires that when performing bitwise operations between columns
6+
* Types that can be bitwise ORed, ANDed, or XORed by Catalyst. Note that Catalyst requires that when performing bitwise operations between columns
87
* the two types must be the same so in some cases casting is necessary.
98
*/
109
@implicitNotFound("Cannot do bitwise operations on columns of type ${A}.")

core/src/main/scala/frameless/CatalystCast.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ object CatalystCast {
88

99
implicit def framelessCastToString[T]: CatalystCast[T, String] = of[T, String]
1010

11-
implicit def framelessNumericToLong [A: CatalystNumeric]: CatalystCast[A, Long] = of[A, Long]
12-
implicit def framelessNumericToInt [A: CatalystNumeric]: CatalystCast[A, Int] = of[A, Int]
13-
implicit def framelessNumericToShort [A: CatalystNumeric]: CatalystCast[A, Short] = of[A, Short]
14-
implicit def framelessNumericToByte [A: CatalystNumeric]: CatalystCast[A, Byte] = of[A, Byte]
11+
implicit def framelessNumericToLong[A: CatalystNumeric]: CatalystCast[A, Long] = of[A, Long]
12+
implicit def framelessNumericToInt[A: CatalystNumeric]: CatalystCast[A, Int] = of[A, Int]
13+
implicit def framelessNumericToShort[A: CatalystNumeric]: CatalystCast[A, Short] = of[A, Short]
14+
implicit def framelessNumericToByte[A: CatalystNumeric]: CatalystCast[A, Byte] = of[A, Byte]
1515
implicit def framelessNumericToDecimal[A: CatalystNumeric]: CatalystCast[A, BigDecimal] = of[A, BigDecimal]
16-
implicit def framelessNumericToDouble [A: CatalystNumeric]: CatalystCast[A, Double] = of[A, Double]
16+
implicit def framelessNumericToDouble[A: CatalystNumeric]: CatalystCast[A, Double] = of[A, Double]
1717

1818
implicit def framelessBooleanToNumeric[A: CatalystNumeric]: CatalystCast[Boolean, A] = of[Boolean, A]
1919

2020
// doesn't make any sense to include:
2121
// - sqlDateToBoolean: always None
2222
// - sqlTimestampToBoolean: compares us to 0
23-
implicit val framelessStringToBoolean : CatalystCast[String, Option[Boolean]] = of[String, Option[Boolean]]
24-
implicit val framelessLongToBoolean : CatalystCast[Long, Boolean] = of[Long, Boolean]
25-
implicit val framelessIntToBoolean : CatalystCast[Int, Boolean] = of[Int, Boolean]
26-
implicit val framelessShortToBoolean : CatalystCast[Short, Boolean] = of[Short, Boolean]
27-
implicit val framelessByteToBoolean : CatalystCast[Byte, Boolean] = of[Byte, Boolean]
28-
implicit val framelessBigDecimalToBoolean: CatalystCast[BigDecimal, Boolean] = of[BigDecimal, Boolean]
29-
implicit val framelessDoubleToBoolean : CatalystCast[Double, Boolean] = of[Double, Boolean]
23+
implicit val framelessStringToBoolean: CatalystCast[String, Option[Boolean]] = of[String, Option[Boolean]]
24+
implicit val framelessLongToBoolean: CatalystCast[Long, Boolean] = of[Long, Boolean]
25+
implicit val framelessIntToBoolean: CatalystCast[Int, Boolean] = of[Int, Boolean]
26+
implicit val framelessShortToBoolean: CatalystCast[Short, Boolean] = of[Short, Boolean]
27+
implicit val framelessByteToBoolean: CatalystCast[Byte, Boolean] = of[Byte, Boolean]
28+
implicit val framelessBigDecimalToBoolean: CatalystCast[BigDecimal, Boolean] = of[BigDecimal, Boolean]
29+
implicit val framelessDoubleToBoolean: CatalystCast[Double, Boolean] = of[Double, Boolean]
3030

3131
// TODO
3232

@@ -38,9 +38,8 @@ object CatalystCast {
3838
// implicit object stringToLong extends CatalystCast[String, Option[Long]]
3939
// implicit object stringToSqlDate extends CatalystCast[String, Option[SQLDate]]
4040

41-
4241
// needs verification:
43-
//implicit object sqlTimestampToSqlDate extends CatalystCast[SQLTimestamp, SQLDate]
42+
// implicit object sqlTimestampToSqlDate extends CatalystCast[SQLTimestamp, SQLDate]
4443

4544
// needs verification:
4645
// implicit object sqlTimestampToDecimal extends CatalystCast[SQLTimestamp, BigDecimal]

core/src/main/scala/frameless/CatalystCollection.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ object CatalystCollection {
99
private[this] val theInstance = new CatalystCollection[Any] {}
1010
private[this] def of[A[_]]: CatalystCollection[A] = theInstance.asInstanceOf[CatalystCollection[A]]
1111

12-
implicit val arrayObject : CatalystCollection[Array] = of[Array]
13-
implicit val seqObject : CatalystCollection[Seq] = of[Seq]
14-
implicit val listObject : CatalystCollection[List] = of[List]
12+
implicit val arrayObject: CatalystCollection[Array] = of[Array]
13+
implicit val seqObject: CatalystCollection[Seq] = of[Seq]
14+
implicit val listObject: CatalystCollection[List] = of[List]
1515
implicit val vectorObject: CatalystCollection[Vector] = of[Vector]
1616
}

0 commit comments

Comments
 (0)