Skip to content

Commit

Permalink
Upgrade sbt and sbt plugins / Clean up
Browse files Browse the repository at this point in the history
* sbt-devoops to 3.0.0
* sbt-docusaur to 0.15.0
* Clean up the code as suggested by sbt-tpolecat
  • Loading branch information
kevin-lee committed Nov 23, 2023
1 parent baf02cf commit 98188cd
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 369 deletions.
126 changes: 73 additions & 53 deletions .scalafix-scala2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,78 @@ rules = [
LeakingImplicitClassVal
NoValInForComprehension
ProcedureSyntax
RedundantSyntax
RemoveUnused

# xuwei-k/scalafix-rules
AddExplicitImplicitTypes
AddLambdaParamParentheses
CirceCodec
CollectHead
CollectHeadOption

FlatTraverse
ImplicitValueClass
KindProjector
LambdaParamParentheses
MapDistinctSize
MapSequenceTraverse
NoElse
ObjectSelfType
OptionMapFlatMap
OptionMatchToRight

SimplifyForYield
ThrowableToNonFatal
UnnecessaryCase
UnnecessaryMatch
UnnecessarySort

UnusedConstructorParams
UnusedTypeParams
WithFilter
]
DisableSyntax.noVars = true
DisableSyntax.noThrows = true
DisableSyntax.noNulls = true
DisableSyntax.noReturns = true
DisableSyntax.noWhileLoops = true
DisableSyntax.noAsInstanceOf = true
DisableSyntax.noIsInstanceOf = true
DisableSyntax.noXml = true
DisableSyntax.noDefaultArgs = true
DisableSyntax.noFinalVal = true
DisableSyntax.noFinalize = true
DisableSyntax.noValPatterns = true
DisableSyntax.regex = []

DisableSyntax {
noVars = true
noThrows = true
noNulls = true
noReturns = true
noWhileLoops = true
noAsInstanceOf = true
noIsInstanceOf = true
noXml = true
noDefaultArgs = true
noFinalVal = true
noFinalize = true
noValPatterns = true
regex = []
}

RemoveUnused {
imports = true
privates = true
locals = true
patternvars = true
params = true
}
//rules = [
// DisableSyntax
// LeakingImplicitClassVal
// NoValInForComprehension
// ProcedureSyntax
// RedundantSyntax
// RemoveUnused
//
// # xuwei-k/scalafix-rules
// AddExplicitImplicitTypes
// AddLambdaParamParentheses
// CirceCodec
// CollectHead
// CollectHeadOption
//
// FlatTraverse
// ImplicitValueClass
// KindProjector
// LambdaParamParentheses
// MapDistinctSize
// MapSequenceTraverse
// NoElse
// ObjectSelfType
// OptionMapFlatMap
// OptionMatchToRight
//
// SimplifyForYield
// ThrowableToNonFatal
// UnnecessaryCase
// UnnecessaryMatch
// UnnecessarySort
//
// UnusedConstructorParams
// UnusedTypeParams
// WithFilter
//]
//
//DisableSyntax {
// noVars = true
// noThrows = true
// noNulls = true
// noReturns = true
// noWhileLoops = true
// noAsInstanceOf = true
// noIsInstanceOf = true
// noXml = true
// noDefaultArgs = true
// noFinalVal = true
// noFinalize = true
// noValPatterns = true
// regex = []
//}
//
//RemoveUnused {
// imports = true
// privates = true
// locals = true
// patternvars = true
// params = true
//}
107 changes: 63 additions & 44 deletions .scalafix-scala3.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,68 @@ rules = [
DisableSyntax
LeakingImplicitClassVal
NoValInForComprehension
RedundantSyntax

# xuwei-k/scalafix-rules
AddExplicitImplicitTypes
AddLambdaParamParentheses
CirceCodec
CollectHead
CollectHeadOption

FlatTraverse
ImplicitValueClass
KindProjector
LambdaParamParentheses
MapDistinctSize
MapSequenceTraverse
NoElse
ObjectSelfType
OptionMapFlatMap
OptionMatchToRight

SimplifyForYield
ThrowableToNonFatal
UnnecessaryCase
UnnecessaryMatch
UnnecessarySort

UnusedConstructorParams
UnusedTypeParams
WithFilter
]
DisableSyntax.noVars = true
DisableSyntax.noThrows = true
DisableSyntax.noNulls = true
DisableSyntax.noReturns = true
DisableSyntax.noWhileLoops = true
DisableSyntax.noAsInstanceOf = true
DisableSyntax.noIsInstanceOf = true
DisableSyntax.noXml = true
DisableSyntax.noDefaultArgs = true
DisableSyntax.noFinalVal = true
DisableSyntax.noFinalize = true
DisableSyntax.noValPatterns = true
DisableSyntax.regex = []

DisableSyntax {
noVars = true
noThrows = true
noNulls = true
noReturns = true
noWhileLoops = true
noAsInstanceOf = true
noIsInstanceOf = true
noXml = true
noDefaultArgs = true
noFinalVal = true
noFinalize = true
noValPatterns = true
regex = []
}
//rules = [
// DisableSyntax
// LeakingImplicitClassVal
// NoValInForComprehension
// RedundantSyntax
//
// # xuwei-k/scalafix-rules
// AddExplicitImplicitTypes
// AddLambdaParamParentheses
// CirceCodec
// CollectHead
// CollectHeadOption
//
// FlatTraverse
// ImplicitValueClass
// KindProjector
// LambdaParamParentheses
// MapDistinctSize
// MapSequenceTraverse
// NoElse
// ObjectSelfType
// OptionMapFlatMap
// OptionMatchToRight
//
// SimplifyForYield
// ThrowableToNonFatal
// UnnecessaryCase
// UnnecessaryMatch
// UnnecessarySort
//
// UnusedConstructorParams
// UnusedTypeParams
// WithFilter
//]
//
//DisableSyntax {
// noVars = true
// noThrows = true
// noNulls = true
// noReturns = true
// noWhileLoops = true
// noAsInstanceOf = true
// noIsInstanceOf = true
// noXml = true
// noDefaultArgs = true
// noFinalVal = true
// noFinalize = true
// noValPatterns = true
// regex = []
//}
50 changes: 29 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,31 @@ ThisBuild / licenses := props.licenses

ThisBuild / resolvers += "sonatype-snapshots" at s"https://${props.SonatypeCredentialHost}/content/repositories/snapshots"

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision

ThisBuild / scalafixConfig := (
if (scalaVersion.value.startsWith("3")) file(".scalafix-scala3.conf").some
else file(".scalafix-scala2.conf").some
)

ThisBuild / scalafixScalaBinaryVersion := {
val log = sLog.value
val newVersion = if (scalaVersion.value.startsWith("3")) {
(ThisBuild / scalafixScalaBinaryVersion).value
} else {
CrossVersion.binaryScalaVersion(scalaVersion.value)
}

log.info(
s">> Change ThisBuild / scalafixScalaBinaryVersion from ${(ThisBuild / scalafixScalaBinaryVersion).value} to $newVersion"
//ThisBuild / semanticdbEnabled := true
//ThisBuild / semanticdbVersion := scalafixSemanticdb.revision

ThisBuild / scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
else
((ThisBuild / baseDirectory).value / ".scalafix-scala2.conf").some
)
newVersion
}

ThisBuild / scalafixDependencies += "com.github.xuwei-k" %% "scalafix-rules" % "0.2.12"
//ThisBuild / scalafixScalaBinaryVersion := {
// val log = sLog.value
// val newVersion = if (scalaVersion.value.startsWith("3")) {
// (ThisBuild / scalafixScalaBinaryVersion).value
// } else {
// CrossVersion.binaryScalaVersion(scalaVersion.value)
// }
//
// log.info(
// s">> Change ThisBuild / scalafixScalaBinaryVersion from ${(ThisBuild / scalafixScalaBinaryVersion).value} to $newVersion"
// )
// newVersion
//}

//ThisBuild / scalafixDependencies += "com.github.xuwei-k" %% "scalafix-rules" % "0.2.12"

lazy val loggerF = (project in file("."))
.enablePlugins(DevOopsGitHubReleasePlugin)
Expand Down Expand Up @@ -653,6 +655,12 @@ def projectCommonSettings(projectName: String, crossProject: CrossProject.Builde
.settings(
name := projectName,
licenses := props.licenses,
scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
else
((ThisBuild / baseDirectory).value / ".scalafix-scala2.conf").some
),
/* WartRemover and scalacOptions { */
// , Compile / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value)
// , Test / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ object instancesSpec extends Properties {
runLog[IO](logMsg).unsafeRunSync()

val expected = logMsg match {
case Some(logMsg) =>
case Some(logMsg @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down Expand Up @@ -198,7 +198,7 @@ object instancesSpec extends Properties {
runLog[IO](logMsg).unsafeRunSync()

val expected = logMsg match {
case Some(logMsg) =>
case Some(logMsg @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down Expand Up @@ -290,7 +290,7 @@ object instancesSpec extends Properties {
errorMessages = Vector(n.toString),
)

case Left(msg) =>
case Left(msg @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down Expand Up @@ -332,7 +332,7 @@ object instancesSpec extends Properties {
errorMessages = Vector(n.toString),
)

case Left(msg) =>
case Left(msg @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down Expand Up @@ -366,7 +366,7 @@ object instancesSpec extends Properties {
runLog[IO](eab).unsafeRunSync()

val expected = eab match {
case Right(n) =>
case Right(n @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down Expand Up @@ -408,7 +408,7 @@ object instancesSpec extends Properties {
runLog[IO](eab).unsafeRunSync()

val expected = eab match {
case Right(n) =>
case Right(n @ _) =>
LoggerForTesting(
debugMessages = Vector.empty,
infoMessages = Vector.empty,
Expand Down
Loading

0 comments on commit 98188cd

Please sign in to comment.