diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e2d105..2a301f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,6 +94,10 @@ jobs: if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + - name: Check scalafix lints + if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' 'scalafixAll --check' + - name: scalaJSLink if: matrix.project == 'rootJS' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/scalaJSLinkerResult diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 0000000..10629b4 --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1,8 @@ +rules = [ + LeakingImplicitClassVal, + NoValInForComprehension, + OrganizeImports, + RedundantSyntax +] +OrganizeImports.removeUnused = false +OrganizeImports.groupedImports = AggressiveMerge diff --git a/.scalafmt.conf b/.scalafmt.conf index e155895..907df99 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -25,7 +25,6 @@ indent.extendSite = 4 indent.main = 2 maxColumn = 80 project.git = true -rewrite.imports.sort = original rewrite.rules = [Imports, RedundantBraces, RedundantParens, SortModifiers] rewrite.trailingCommas.style = always rewrite.redundantBraces.maxBreaks = 1 diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecord.scala b/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecord.scala index b5c7ef2..1bc6989 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecord.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecord.scala @@ -23,6 +23,7 @@ package com.github.tarao.record4s import scala.deriving.Mirror import scala.language.dynamics + import typing.ArrayRecord.{Aux, Concat, Lookup} import typing.Record.{Select, Unselect} import util.SeqOps.deduped diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecordMacros.scala b/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecordMacros.scala index 5ecbe4b..38e1ee5 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecordMacros.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/ArrayRecordMacros.scala @@ -22,6 +22,7 @@ package com.github.tarao.record4s import scala.annotation.nowarn + import typing.ArrayRecord.{Concat, Lookup} import util.SeqOps.deduped diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/InternalMacros.scala b/modules/core/src/main/scala/com/github/tarao/record4s/InternalMacros.scala index 2805d58..02282af 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/InternalMacros.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/InternalMacros.scala @@ -22,6 +22,7 @@ package com.github.tarao.record4s import scala.annotation.tailrec + import util.SeqOps.deduped private[record4s] class InternalMacros(using @@ -315,7 +316,7 @@ private[record4s] class InternalMacros(using fieldTypeOf(labelExpr, valueExpr) case expr => - errorAndAbort(s"Invalid field", Some(expr)) + errorAndAbort("Invalid field", Some(expr)) } } diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/Macros.scala b/modules/core/src/main/scala/com/github/tarao/record4s/Macros.scala index 529f812..8f302da 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/Macros.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/Macros.scala @@ -22,6 +22,7 @@ package com.github.tarao.record4s import scala.annotation.nowarn + import typing.Record.{Concat, Lookup, Select, Unselect} @nowarn("msg=unused local") diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/Selector.scala b/modules/core/src/main/scala/com/github/tarao/record4s/Selector.scala index db2c4fa..932bc4b 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/Selector.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/Selector.scala @@ -23,6 +23,7 @@ package com.github.tarao.record4s import scala.compiletime.requireConst import scala.language.dynamics + import typing.Record.Select final class Selector[T <: Tuple](val labels: Seq[String] = Seq.empty) diff --git a/modules/core/src/main/scala/com/github/tarao/record4s/typing/ArrayRecord.scala b/modules/core/src/main/scala/com/github/tarao/record4s/typing/ArrayRecord.scala index 1fe997f..c791bac 100644 --- a/modules/core/src/main/scala/com/github/tarao/record4s/typing/ArrayRecord.scala +++ b/modules/core/src/main/scala/com/github/tarao/record4s/typing/ArrayRecord.scala @@ -66,6 +66,6 @@ object ArrayRecord { } transparent inline given [R, L <: String]: Lookup[R, L] = - ${ ArrayRecordMacros.derivedTypingLookupImpl[R, L] } + ${ ArrayRecordMacros.derivedTypingLookupImpl } } } diff --git a/modules/core/src/test/scala/com/github/tarao/record4s/TypeErrorSpec.scala b/modules/core/src/test/scala/com/github/tarao/record4s/TypeErrorSpec.scala index 6578550..04560f9 100644 --- a/modules/core/src/test/scala/com/github/tarao/record4s/TypeErrorSpec.scala +++ b/modules/core/src/test/scala/com/github/tarao/record4s/TypeErrorSpec.scala @@ -21,7 +21,7 @@ package com.github.tarao.record4s -import scala.compiletime.testing.{typeCheckErrors, Error, ErrorKind} +import scala.compiletime.testing.{Error, ErrorKind, typeCheckErrors} class TypeErrorSpec extends helper.UnitSpec { describe("Typing %") { diff --git a/modules/core/src/test/scala/helper/StaticTypeMatcher.scala b/modules/core/src/test/scala/helper/StaticTypeMatcher.scala index 8580e87..835f29a 100644 --- a/modules/core/src/test/scala/helper/StaticTypeMatcher.scala +++ b/modules/core/src/test/scala/helper/StaticTypeMatcher.scala @@ -21,12 +21,13 @@ package helper -import scala.compiletime.summonInline import org.scalatest.matchers.dsl.{ ResultOfATypeInvocation, ResultOfAnTypeInvocation, } +import scala.compiletime.summonInline + trait StaticTypeMatcher { extension [T1](anything: T1) { inline def shouldStaticallyBe[T2](r: ResultOfATypeInvocation[T2]): Unit = { diff --git a/modules/core/src/test/scala/helper/UnitSpec.scala b/modules/core/src/test/scala/helper/UnitSpec.scala index cdc20b3..c289503 100644 --- a/modules/core/src/test/scala/helper/UnitSpec.scala +++ b/modules/core/src/test/scala/helper/UnitSpec.scala @@ -21,11 +21,8 @@ package helper -import org.scalatest.Inside -import org.scalatest.Inspectors -import org.scalatest.OptionValues import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers +import org.scalatest.{Inside, Inspectors, OptionValues, matchers} abstract class UnitSpec extends AnyFunSpec diff --git a/project/plugins.sbt b/project/plugins.sbt index 2ceac82..f8601f7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,5 @@ -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6") -addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.6.1") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6") +addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.6.1") +addSbtPlugin("org.typelevel" % "sbt-typelevel-scalafix" % "0.6.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")