This is an automated email from the ASF dual-hosted git repository. mdedetrich pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-pekko-http.git
commit 25626716949ef520428912c661cd7a5041ff63e6 Author: Matthew de Detrich <[email protected]> AuthorDate: Mon Nov 14 10:41:48 2022 +0100 Replace scalariform with scalafmt --- .github/workflows/validate-and-test.yml | 4 +- .scalafmt.conf | 77 +++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 +- build.sbt | 3 -- project/Formatting.scala | 36 --------------- project/MultiNode.scala | 9 ++-- project/plugins.sbt | 2 +- 7 files changed, 84 insertions(+), 49 deletions(-) diff --git a/.github/workflows/validate-and-test.yml b/.github/workflows/validate-and-test.yml index 845040ec7..3887cc8fe 100644 --- a/.github/workflows/validate-and-test.yml +++ b/.github/workflows/validate-and-test.yml @@ -33,8 +33,8 @@ jobs: path: project/**/target key: build-target-${{ hashFiles('**/*.sbt', 'project/build.properties', 'project/**/*.scala') }} - - name: Autoformat - run: sbt +headerCreateAll +scalariformFormat +test:scalariformFormat + - name: Check code is formatted + run: sbt scalafmtCheckAll scalafmtSbtCheck headerCheckAll - name: Check for missing formatting run: git diff --exit-code --color diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 000000000..efa297ee4 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,77 @@ +version = 3.6.1 +runner.dialect = scala213 +project.git = true +style = defaultWithAlign +docstrings.style = Asterisk +docstrings.wrap = false +indentOperator.preset = spray +maxColumn = 120 +lineEndings = preserve +rewrite.rules = [RedundantParens, SortImports, AvoidInfix] +indentOperator.exemptScope = all +align.preset = some +align.tokens."+" = [ + { + code = "~>" + owners = [ + { regex = "Term.ApplyInfix" } + ] + } +] +literals.hexDigits = upper +literals.hexPrefix = lower +binPack.unsafeCallSite = always +binPack.unsafeDefnSite = always +binPack.indentCallSiteSingleArg = false +binPack.indentCallSiteOnce = true +newlines.avoidForSimpleOverflow = [slc] +newlines.source = keep +newlines.beforeMultiline = keep +align.openParenDefnSite = false +align.openParenCallSite = false +align.allowOverflow = true +optIn.breakChainOnFirstMethodDot = false +optIn.configStyleArguments = false +danglingParentheses.preset = false +spaces.inImportCurlyBraces = true +rewrite.neverInfix.excludeFilters = [ + and + min + max + until + to + by + eq + ne + "should.*" + "contain.*" + "must.*" + in + ignore + be + taggedAs + thrownBy + synchronized + have + when + size + only + noneOf + oneElementOf + noElementsOf + atLeastOneElementOf + atMostOneElementOf + allElementsOf + inOrderElementsOf + theSameElementsAs + theSameElementsInOrderAs +] +rewriteTokens = { + "⇒": "=>" + "→": "->" + "←": "<-" +} +project.excludeFilters = [ + "scripts/authors.scala" +] +project.layout = StandardConvention diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 770a1356f..4ecda37c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -283,7 +283,7 @@ the validator to test all projects. ### Scala style -Akka-http uses [Scalariform](https://github.com/scala-ide/scalariform) to enforce some of the code style rules. +Akka-http uses [scalafmt](https://scalameta.org/scalafmt/) to enforce some of the code style rules. ### Java style diff --git a/build.sbt b/build.sbt index f16fb94d8..260d0c359 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,6 @@ import akka.ValidatePullRequest._ import AkkaDependency._ import Dependencies.{h2specExe, h2specName} import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm -import com.typesafe.sbt.SbtScalariform.ScalariformKeys import java.nio.file.Files import java.nio.file.attribute.{PosixFileAttributeView, PosixFilePermission} @@ -34,7 +33,6 @@ inThisBuild(Def.settings( Tests.Argument(TestFrameworks.ScalaTest, "-oDF") ), Dependencies.Versions, - Formatting.formatSettings, shellPrompt := { s => Project.extract(s).currentProject.id + " > " }, concurrentRestrictions in Global += Tags.limit(Tags.Test, 1), onLoad in Global := { @@ -465,7 +463,6 @@ lazy val docs = project("docs") "github.base_url" -> GitHub.url(version.value, isSnapshot.value), ), apidocRootPackage := "akka", - Formatting.docFormatSettings, ValidatePR / additionalTasks += Compile / paradox, ThisBuild / publishRsyncHost := "[email protected]", publishRsyncArtifacts := List((Compile / paradox).value -> gustavDir("docs").value), diff --git a/project/Formatting.scala b/project/Formatting.scala deleted file mode 100644 index 85e93a27c..000000000 --- a/project/Formatting.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2017-2020 Lightbend Inc. <https://www.lightbend.com> - */ - -package akka - -import sbt._ -import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm -import com.typesafe.sbt.SbtScalariform.ScalariformKeys - -object Formatting { - import scalariform.formatter.preferences._ - - lazy val formatSettings = Seq( - ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value), - Compile / ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value), - MultiJvm / ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value) - ) - - lazy val docFormatSettings = Seq( - ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value), - Compile / ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value), - Test / ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value), - MultiJvm / ScalariformKeys.preferences := setPreferences(ScalariformKeys.preferences.value) - ) - - def setPreferences(preferences: IFormattingPreferences) = preferences - .setPreference(RewriteArrowSymbols, true) - .setPreference(UseUnicodeArrows, false) - .setPreference(AlignParameters, true) - .setPreference(AlignSingleLineCaseStatements, true) - .setPreference(DoubleIndentConstructorArguments, false) - .setPreference(DoubleIndentMethodDeclaration, false) - .setPreference(DanglingCloseParenthesis, Preserve) - .setPreference(NewlineAtEndOfFile, true) -} diff --git a/project/MultiNode.scala b/project/MultiNode.scala index be0251006..de6d6d924 100644 --- a/project/MultiNode.scala +++ b/project/MultiNode.scala @@ -4,9 +4,8 @@ package akka -import com.typesafe.sbt.{SbtMultiJvm, SbtScalariform} +import com.typesafe.sbt.SbtMultiJvm import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys._ -import com.typesafe.sbt.SbtScalariform.ScalariformKeys import sbt._ import sbt.Keys._ @@ -50,13 +49,11 @@ object MultiNode extends AutoPlugin { private val multiJvmSettings = SbtMultiJvm.multiJvmSettings ++ - inConfig(MultiJvm)(SbtScalariform.configScalariformSettings) ++ - Seq( + inConfig(MultiJvm)(Seq( MultiJvm / jvmOptions := defaultMultiJvmOptions, - MultiJvm / compile / compileInputs := ((MultiJvm / compile / compileInputs) dependsOn (MultiJvm / ScalariformKeys.format)).value, MultiJvm / scalacOptions := (Test / scalacOptions).value, MultiJvm / compile := ((MultiJvm / compile) triggeredBy (Test / compile)).value - ) ++ + )) ++ CliOptions.hostsFileName.map(MultiJvm / multiNodeHostsFileName := _) ++ CliOptions.javaName.map(MultiJvm / multiNodeJavaName := _) ++ CliOptions.targetDirName.map(MultiJvm / multiNodeTargetDirName := _) ++ diff --git a/project/plugins.sbt b/project/plugins.sbt index 8e86d0e95..383dba0c7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,7 +8,7 @@ resolvers += Resolver.jcenterRepo addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.4.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0") -addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
