From 602d5a54a9f4ced474a76f4106a1c5159405a4cf Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Tue, 17 Oct 2017 15:44:11 -0700 Subject: Proposed scalafmt settings (#26) --- src/main/resources/scalafmt.conf | 5 ++-- src/main/scala/xyz.driver.sbt/SbtSettings.scala | 34 +++++++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/main/resources/scalafmt.conf b/src/main/resources/scalafmt.conf index 8a5d14f..e4f440d 100644 --- a/src/main/resources/scalafmt.conf +++ b/src/main/resources/scalafmt.conf @@ -9,7 +9,7 @@ maxColumn = 120 docstrings = ScalaDoc continuationIndent.callSite = 2 -continuationIndent.defnSite = 8 +continuationIndent.defnSite = 4 rewriteTokens: { "⇒" = "=>" @@ -17,7 +17,8 @@ rewriteTokens: { } danglingParentheses = false align.arrowEnumeratorGenerator = true -align.openParenCallSite = true +align.openParenCallSite = false +align.openParenDefnSite = false spaces.afterTripleEquals = true spaces.inImportCurlyBraces = false newlines.alwaysBeforeCurlyBraceLambdaParams = false diff --git a/src/main/scala/xyz.driver.sbt/SbtSettings.scala b/src/main/scala/xyz.driver.sbt/SbtSettings.scala index b500d4a..c98bb4c 100644 --- a/src/main/scala/xyz.driver.sbt/SbtSettings.scala +++ b/src/main/scala/xyz.driver.sbt/SbtSettings.scala @@ -39,20 +39,44 @@ object SbtSettings extends AutoPlugin { } Seq( + scalafmtVersion := "1.3.0", resourceGenerators in Compile += generateScalafmtConfTask.taskValue, + // it:scalafmt -> runs scalafmt in src/it + scalafmt in IntegrationTest := { + // Explicit dependency to generating .scalafmt.conf file, otherwise there is no guarantee on execution order + (scalafmt in IntegrationTest).dependsOn(generateScalafmtConfTask).value + }, + // test:scalafmt -> runs scalafmt in src/test + src/it + scalafmt in Test := { + // By transitive dependency Test depends on generateScalafmtConfTask. No need to explicitly add it here. + (scalafmt in Test).dependsOn(scalafmt in IntegrationTest).value + }, + // scalafmt -> runs scalafmt in src/main + src/test + src/it scalafmt in Compile := { - generateScalafmtConfTask.value - (scalafmt in Compile).value + // By transitive dependency Compile depends on generateScalafmtConfTask. No need to explicitly add it here. + (scalafmt in Compile).dependsOn(scalafmt in Test).value + }, + // it:scalafmt::test -> tests scalafmt format in src/it + test in scalafmt in IntegrationTest := { + // Explicit dependency to generating .scalafmt.conf file, otherwise there is no guarantee on execution order + (test in scalafmt in IntegrationTest).dependsOn(generateScalafmtConfTask).value + }, + // test:scalafmt::test -> tests scalafmt format in src/test + src/it + test in scalafmt in Test := { + // By transitive dependency Test depends on generateScalafmtConfTask. No need to explicitly add it here. + (test in scalafmt in Test).dependsOn(test in scalafmt in IntegrationTest).value }, + // scalafmt::test -> tests scalafmt format in src/main + src/test (added behavior) test in scalafmt in Compile := { - generateScalafmtConfTask.value - (test in scalafmt in Compile).value + // By transitive dependency Compile depends on generateScalafmtConfTask. No need to explicitly add it here. + (test in scalafmt in Compile).dependsOn(test in scalafmt in Test).value + }, test in Test := { (test in scalafmt in Compile).value (test in Test).value } - ) + ) ++ inConfig(IntegrationTest)(scalafmtSettings) } lazy val testScalastyle = taskKey[Unit]("testScalastyle") -- cgit v1.2.3