From ad5a6d4462892029ce8b0f6a234ee345233de660 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 11 Nov 2024 10:46:32 +0900 Subject: [PATCH] Update scalafmt settings. enforce new syntax --- .github/workflows/format.yml | 11 +++++++--- .scalafmt.conf | 6 +++++- src/main/scala-2.12/PluginCompat.scala | 2 +- src/main/scala-3/PluginCompat.scala | 2 +- src/main/scala/flywaysbt/FlywayPlugin.scala | 24 ++++++++++----------- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 31dd5d4..158945b 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -17,7 +17,12 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Check project is formatted - uses: jrouly/scalafmt-native-action@v4 + - uses: actions/setup-java@v4 with: - arguments: '--list' + distribution: temurin + java-version: 8 + + - uses: sbt/setup-sbt@v1 + + - name: Check project is formatted + run: sbt scalafmtSbtCheck "+ scalafmtCheckAll" diff --git a/.scalafmt.conf b/.scalafmt.conf index bb54dc3..f025c0b 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ version = 3.8.3 -runner.dialect = scala212 +runner.dialect = scala212source3 maxColumn = 120 project.git = true @@ -28,3 +28,7 @@ align.tokens."+" = [ ] project.layout = StandardConvention +rewrite.scala3.convertToNewSyntax = true +rewrite.scala3.newSyntax.control = false +runner.dialectOverride.allowUnderscoreAsTypePlaceholder = false +runner.dialectOverride.allowSignificantIndentation = false diff --git a/src/main/scala-2.12/PluginCompat.scala b/src/main/scala-2.12/PluginCompat.scala index e3ee141..d90fc49 100644 --- a/src/main/scala-2.12/PluginCompat.scala +++ b/src/main/scala-2.12/PluginCompat.scala @@ -1,6 +1,6 @@ package flywaysbt -import java.nio.file.{ Path => NioPath } +import java.nio.file.{ Path as NioPath } import java.io.File import sbt.Attributed import xsbti.FileConverter diff --git a/src/main/scala-3/PluginCompat.scala b/src/main/scala-3/PluginCompat.scala index a54d2f1..273c0ba 100644 --- a/src/main/scala-3/PluginCompat.scala +++ b/src/main/scala-3/PluginCompat.scala @@ -1,6 +1,6 @@ package flywaysbt -import java.nio.file.{ Path => NioPath } +import java.nio.file.{ Path as NioPath } import sbt.* import xsbti.{ FileConverter, HashedVirtualFileRef, VirtualFile } diff --git a/src/main/scala/flywaysbt/FlywayPlugin.scala b/src/main/scala/flywaysbt/FlywayPlugin.scala index 9ef6111..1aa7ac8 100644 --- a/src/main/scala/flywaysbt/FlywayPlugin.scala +++ b/src/main/scala/flywaysbt/FlywayPlugin.scala @@ -231,13 +231,13 @@ object FlywayPlugin extends AutoPlugin { // ********************* // flyway defaults // ********************* - override def projectSettings: Seq[Setting[_]] = + override def projectSettings: Seq[Setting[?]] = flywayBaseSettings(Runtime) ++ inConfig(Test)(flywayBaseSettings(Test)) - def flywayBaseSettings(conf: Configuration): Seq[Setting[_]] = { - import FlywayPlugin.autoImport._ + def flywayBaseSettings(conf: Configuration): Seq[Setting[?]] = { + import FlywayPlugin.autoImport.* val defaults = getFlywayDefaults - Seq[Setting[_]]( + Seq[Setting[?]]( flywayDriver := "", flywayUrl := "", flywayUser := "", @@ -302,7 +302,7 @@ object FlywayPlugin extends AutoPlugin { flywaySqlMigrationPrefix.value, flywayRepeatableSqlMigrationPrefix.value, flywaySqlMigrationSeparator.value, - flywaySqlMigrationSuffixes.value: _* + flywaySqlMigrationSuffixes.value* ), flywayConfigMigrate := ConfigMigrate( flywayIgnoreMissingMigrations.value, @@ -406,7 +406,7 @@ object FlywayPlugin extends AutoPlugin { } def configure(config: ConfigBase): FluentConfiguration = { flyway - .schemas(config.schemas: _*) + .schemas(config.schemas*) .table(config.table) .baselineVersion(config.baselineVersion) .baselineDescription(config.baselineDescription) @@ -414,14 +414,14 @@ object FlywayPlugin extends AutoPlugin { } def configure(config: ConfigMigrationLoading): FluentConfiguration = { flyway - .locations(config.locations: _*) + .locations(config.locations*) .encoding(config.encoding) .cleanOnValidationError(config.cleanOnValidationError) .cleanDisabled(config.cleanDisabled) // .target(config.target) Setting this as-is will make the default be "current", which we don't want .outOfOrder(config.outOfOrder) - .callbacks(config.callbacks: _*) - .resolvers(config.resolvers: _*) + .callbacks(config.callbacks*) + .resolvers(config.resolvers*) .skipDefaultResolvers(config.skipDefaultResolvers) .skipDefaultCallbacks(config.skipDefaultCallbacks) .validateMigrationNaming(config.validateMigrationNaming) @@ -431,12 +431,12 @@ object FlywayPlugin extends AutoPlugin { .sqlMigrationPrefix(config.sqlMigrationPrefix) .repeatableSqlMigrationPrefix(config.repeatableSqlMigrationPrefix) .sqlMigrationSeparator(config.sqlMigrationSeparator) - .sqlMigrationSuffixes(config.sqlMigrationSuffixes: _*) + .sqlMigrationSuffixes(config.sqlMigrationSuffixes*) } def configure(config: ConfigMigrate): FluentConfiguration = { flyway - .ignoreMigrationPatterns(config.ignorePatterns: _*) + .ignoreMigrationPatterns(config.ignorePatterns*) .baselineOnMigrate(config.baselineOnMigrate) .validateOnMigrate(config.validateOnMigrate) .mixed(config.mixed) @@ -459,7 +459,7 @@ object FlywayPlugin extends AutoPlugin { } private object SbtLogCreator extends LogCreator { - def createLogger(clazz: Class[_]): FlywaySbtLog.type = FlywaySbtLog + def createLogger(clazz: Class[?]): FlywaySbtLog.type = FlywaySbtLog } private object FlywaySbtLog extends Log {