From 77ef2414493a9dc45f99767a9d58d9b48fb4c55e Mon Sep 17 00:00:00 2001 From: Diego Casella Date: Fri, 22 Mar 2024 22:48:02 +0100 Subject: [PATCH] chore: included scalafix to tidy imports * prepare for release 0.3.0 * run `fmtCheck` before the tests --- .github/workflows/scala.yml | 7 +++---- .scalafix.conf | 7 ++++--- build.sbt | 4 ++-- .../io/github/polentino/redacted/helpers/PluginOps.scala | 7 ++++--- .../github/polentino/redacted/phases/PatchToString.scala | 8 ++++---- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index 7e60c0d..89f44d3 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -2,7 +2,6 @@ # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. - name: Scala CI on: @@ -26,8 +25,8 @@ jobs: java-version: '11' distribution: 'temurin' cache: 'sbt' - - name: Run tests - run: sbt test + - name: Check formatting & Run Tests + run: sbt fmtCheck test # Optional: This step uploads information to the GitHub dependency graph and unblocking Dependabot alerts for the repository - name: Upload dependency graph - uses: scalacenter/sbt-dependency-submission@ab086b50c947c9774b70f39fc7f6e20ca2706c91 + uses: scalacenter/sbt-dependency-submission@ab086b50c947c9774b70f39fc7f6e20ca2706c91 \ No newline at end of file diff --git a/.scalafix.conf b/.scalafix.conf index 0c65d47..126dea2 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -2,14 +2,15 @@ rules = [ OrganizeImports ] OrganizeImports { blankLines = Auto - coalesceToWildcardImportThreshold = 2 + coalesceToWildcardImportThreshold = 3 expandRelative = false groupExplicitlyImportedImplicitsSeparately = false groupedImports = AggressiveMerge groups = [ - "*" - "re:(javax?|scala|dotty)\\." + "re:(dotty)\\." + "re:(scala)\\." "re:(io\\.github\\.polentino\\.)" + "*" ] importSelectorsOrder = Ascii importsOrder = Ascii diff --git a/build.sbt b/build.sbt index da0e86e..3d637f3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -ThisBuild / version := "0.3.0-SNAPSHOT" +ThisBuild / version := "0.3.0" ThisBuild / scalaVersion := "3.1.3" ThisBuild / publishMavenStyle := true @@ -79,5 +79,5 @@ lazy val redactedTests = (project in file("tests")) } ) -addCommandAlias("fmt", "; scalafmtAll ; scalafmtSbt") // todo scalafix ? +addCommandAlias("fmt", "; scalafix; scalafmtAll; scalafmtSbt") addCommandAlias("fmtCheck", "; scalafmtCheckAll ; scalafmtSbtCheck") diff --git a/plugin/src/main/scala/io/github/polentino/redacted/helpers/PluginOps.scala b/plugin/src/main/scala/io/github/polentino/redacted/helpers/PluginOps.scala index d8de7fa..9fb0e6a 100644 --- a/plugin/src/main/scala/io/github/polentino/redacted/helpers/PluginOps.scala +++ b/plugin/src/main/scala/io/github/polentino/redacted/helpers/PluginOps.scala @@ -1,19 +1,20 @@ package io.github.polentino.redacted.helpers import dotty.tools.dotc.* -import dotty.tools.dotc.ast.{tpd, *} import dotty.tools.dotc.ast.tpd.* import dotty.tools.dotc.ast.untpd.Modifiers -import dotty.tools.dotc.core.* +import dotty.tools.dotc.ast.{tpd, *} import dotty.tools.dotc.core.Constants.Constant import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.core.Names.TermName import dotty.tools.dotc.core.Symbols.* +import dotty.tools.dotc.core.* import dotty.tools.dotc.util.Spans.Span -import io.github.polentino.redacted.helpers.AstOps.* import scala.util.{Failure, Success, Try} +import io.github.polentino.redacted.helpers.AstOps.* + object PluginOps { private val TO_STRING_NAME = "toString" diff --git a/plugin/src/main/scala/io/github/polentino/redacted/phases/PatchToString.scala b/plugin/src/main/scala/io/github/polentino/redacted/phases/PatchToString.scala index f516cbf..ff11f25 100644 --- a/plugin/src/main/scala/io/github/polentino/redacted/phases/PatchToString.scala +++ b/plugin/src/main/scala/io/github/polentino/redacted/phases/PatchToString.scala @@ -2,16 +2,16 @@ package io.github.polentino.redacted.phases import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.core.Contexts.* -import dotty.tools.dotc.core.Symbols -import dotty.tools.dotc.core.Names +import dotty.tools.dotc.core.{Names, Symbols} import dotty.tools.dotc.plugins.PluginPhase import dotty.tools.dotc.report import dotty.tools.dotc.transform.Pickler -import io.github.polentino.redacted.helpers.PluginOps.* -import io.github.polentino.redacted.helpers.AstOps.* import scala.util.Try +import io.github.polentino.redacted.helpers.AstOps.* +import io.github.polentino.redacted.helpers.PluginOps.* + final case class PatchToString() extends PluginPhase { override val runsAfter: Set[String] = Set(Pickler.name)