diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000000..9f2ddaac28 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,8 @@ +version = 3.0.4 +maxColumn = 110 +docstrings.style = Asterisk +newlines.alwaysBeforeMultilineDef = false +newlines.penalizeSingleSelectMultiArgList = false +align.openParenCallSite = false +rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, PreferCurlyFors] +rewrite.redundantBraces.generalExpressions = false \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4ab8d832be..ce49c5d70d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,11 @@ addons: matrix: include: +# - scala: 2.11.12 +# env: BUILD="check code formatting" +# script: +# - ./sbt ++$TRAVIS_SCALA_VERSION clean scalafmtSbtCheck scalafmtCheckAll + #BASE TESTS - scala: 2.11.12 env: BUILD="base" TEST_TARGET="scalding-args scalding-date maple scalding-quotation" diff --git a/build.sbt b/build.sbt index b6473ca5a0..55f336f5ed 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,6 @@ import ReleaseTransformations._ -import com.typesafe.sbt.SbtScalariform.scalariformSettings -import com.typesafe.sbt.SbtScalariform.ScalariformKeys import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings import scala.collection.JavaConverters._ -import scalariform.formatter.preferences._ import microsites.ExtraMdFileConfig def scalaBinaryVersion(scalaVersion: String) = scalaVersion match { @@ -43,15 +40,13 @@ val jlineVersion = "2.14.3" val printDependencyClasspath = taskKey[Unit]("Prints location of the dependencies") -val sharedSettings = scalariformSettings ++ Seq( +val sharedSettings = Seq( organization := "com.twitter", scalaVersion := "2.11.12", crossScalaVersions := Seq(scalaVersion.value, "2.12.14"), - ScalariformKeys.preferences := formattingPreferences, - javacOptions ++= Seq("-source", "1.8", "-target", "1.8"), doc / javacOptions := Seq("-source", "1.8"), @@ -87,7 +82,7 @@ val sharedSettings = scalariformSettings ++ Seq( update / aggregate := false, - Test / javaOptions ++= Seq("-Xmx2048m", "-XX:ReservedCodeCacheSize=384m", "-XX:MaxPermSize=384m"), + Test / javaOptions ++= Seq("-Xmx2048m", "-XX:ReservedCodeCacheSize=384m"), Global / concurrentRestrictions := Seq( Tags.limitAll(1) @@ -251,13 +246,6 @@ lazy val scaldingAssembly = Project( scaldingSerialization ) -lazy val formattingPreferences = { - import scalariform.formatter.preferences._ - FormattingPreferences(). - setPreference(AlignParameters, false). - setPreference(PreserveSpaceBeforeArguments, true) -} - lazy val noPublishSettings = Seq( publish := (()), publishLocal := (()), diff --git a/project/plugins.sbt b/project/plugins.sbt index 134661c9a0..755c21658c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -13,7 +13,7 @@ addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "18.9.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") -addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.16") diff --git a/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/PlatformTest.scala b/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/PlatformTest.scala index 002dc6eaae..c26a1f9a56 100644 --- a/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/PlatformTest.scala +++ b/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/PlatformTest.scala @@ -651,8 +651,8 @@ class PlatformTest extends WordSpec with Matchers with HadoopSharedPlatformTest "reduce stage - sum", "write", // should see the .group and the .write show up as line numbers - "com.twitter.scalding.platform.TypedPipeWithDescriptionJob.(TestJobsWithDescriptions.scala:30)", - "com.twitter.scalding.platform.TypedPipeWithDescriptionJob.(TestJobsWithDescriptions.scala:34)") + "com.twitter.scalding.platform.TypedPipeWithDescriptionJob.(TestJobsWithDescriptions.scala:31)", + "com.twitter.scalding.platform.TypedPipeWithDescriptionJob.(TestJobsWithDescriptions.scala:35)") val foundDescs = steps.map(_.getConfig.get(Config.StepDescriptions)) descs.foreach { d => diff --git a/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/TestJobsWithDescriptions.scala b/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/TestJobsWithDescriptions.scala index b50c26e8e7..7a7198e5fb 100644 --- a/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/TestJobsWithDescriptions.scala +++ b/scalding-hadoop-test/src/test/scala/com/twitter/scalding/platform/TestJobsWithDescriptions.scala @@ -24,9 +24,10 @@ class TypedPipeJoinWithDescriptionJob(args: Args) extends Job(args) { } class TypedPipeWithDescriptionJob(args: Args) extends Job(args) { - TypedPipe.from[String](List("word1", "word1", "word2")) + TypedPipe + .from[String](List("word1", "word1", "word2")) .withDescription("map stage - assign words to 1") - .map { w => (w, 1L) } + .map(w => (w, 1L)) .group .withDescription("reduce stage - sum") .sum diff --git a/scalding-quotation/src/test/scala/com/twitter/scalding/quotation/TextMacroTest.scala b/scalding-quotation/src/test/scala/com/twitter/scalding/quotation/TextMacroTest.scala index c2bf3c1bac..626340e04c 100644 --- a/scalding-quotation/src/test/scala/com/twitter/scalding/quotation/TextMacroTest.scala +++ b/scalding-quotation/src/test/scala/com/twitter/scalding/quotation/TextMacroTest.scala @@ -65,14 +65,17 @@ class TextMacroTest extends Test { } } "with function" in { - (test.paramGroupsWithFunction(1) { - case 1 => 2 - case _ => 3 - })._1.text mustEqual + test + .paramGroupsWithFunction(1) { + case 1 => 2 + case _ => 3 + } + ._1 + .text mustEqual Some("""paramGroupsWithFunction(1) { - case 1 => 2 - case _ => 3 - }""") + case 1 => 2 + case _ => 3 + }""") } } @@ -85,7 +88,7 @@ class TextMacroTest extends Test { test.function { case _ => 4 }._1.text mustEqual Some("function { case _ => 4 }") } "curly braces" in { - test.function { _ + 1 }._1.text mustEqual Some("function { _ + 1 }") + test.function(_ + 1)._1.text mustEqual Some("function(_ + 1)") } } @@ -95,8 +98,7 @@ class TextMacroTest extends Test { _ + 1 } c._1.text mustEqual - Some( - """function { + Some("""function { def test = 1 _ + 1 }""") @@ -106,4 +108,4 @@ class TextMacroTest extends Test { test.tupleParam((1, 2))._1.text mustEqual Some("tupleParam((1, 2))") } -} \ No newline at end of file +}