Skip to content

Commit

Permalink
Merge pull request #2144 from scalacenter/update/mdoc-2.6.2
Browse files Browse the repository at this point in the history
Update mdoc to 2.6.2 & metaconfig to 0.14.0
  • Loading branch information
bjaglin authored Dec 21, 2024
2 parents 8668af5 + 7166586 commit ec767bb
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ lazy val docs = projectMatrix
scalacOptions += "-Wconf:msg='match may not be exhaustive':s", // silence exhaustive pattern matching warning for documentation
scalacOptions += "-Xfatal-warnings",
mdoc := (Compile / run).evaluated,
libraryDependencies += metaconfigDoc,
libraryDependencies += scalatags,
dependencyOverrides += scalametaFor3Use2_13 // force eviction of mdoc transitive dependency
)
.defaultAxes(VirtualAxis.jvm)
Expand Down
5 changes: 3 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ object Dependencies {
val commontTextV = "1.13.0"
val googleDiffV = "1.3.0"
val jgitV = "5.13.3.202401111512-r"
val metaconfigV = "0.13.0"
val metaconfigV = "0.14.0"
val nailgunV = "0.9.1"
val scalaXmlV = "2.2.0"
val scalametaV = "4.12.2"
val scalatagsV = "0.13.1"
val scalatestV = "3.2.19"
val munitV = "1.0.3"

Expand All @@ -32,12 +33,12 @@ object Dependencies {
val googleDiff = "com.googlecode.java-diff-utils" % "diffutils" % googleDiffV
val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % jgitV
val metaconfig = "org.scalameta" %% "metaconfig-typesafe-config" % metaconfigV
val metaconfigDoc = "org.scalameta" %% "metaconfig-docs" % metaconfigV
val metacp = "org.scalameta" %% "metacp" % scalametaV
val nailgunServer = "com.martiansoftware" % "nailgun-server" % nailgunV
val scalaXml = "org.scala-lang.modules" %% "scala-xml" % scalaXmlV
val scalametaFor3Use2_13 = "org.scalameta" %% "scalameta" % scalametaV cross CrossVersion.for3Use2_13
val scalametaTeskitFor3Use2_13 = "org.scalameta" %% "testkit" % scalametaV cross CrossVersion.for3Use2_13
val scalatags = "com.lihaoyi" %% "scalatags" % scalatagsV
val scalatest = "org.scalatest" %% "scalatest" % scalatestV
val munit = "org.scalameta" %% "munit" % munitV
val semanticdbScalacCore = "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
Expand Down
19 changes: 12 additions & 7 deletions project/ScalafixBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,22 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
"com.lihaoyi" %% "pprint",
// https://github.com/scalacenter/scalafix/pull/1819#issuecomment-1636118496
"org.scalameta" %% "fastparse-v2",
"com.lihaoyi" %% "geny",
// https://github.com/scalacenter/scalafix/pull/2025#issuecomment-2264188708
"com.geirsson" %% "metaconfig-core",
"com.geirsson" %% "metaconfig-pprint",
"com.geirsson" %% "metaconfig-typesafe-config"
"com.lihaoyi" %% "geny"
),
versionPolicyIgnoredInternalDependencyVersions :=
Some("^\\d+\\.\\d+\\.\\d+\\+\\d+".r),
versionScheme := Some("early-semver"),
// coursier-versions always return false for the *.*.*.*-r pattern jgit uses
libraryDependencySchemes += Dependencies.jgit.withRevision("always")
libraryDependencySchemes ++= Seq(
// coursier-versions always return false for the *.*.*.*-r pattern jgit uses
Dependencies.jgit.withRevision(VersionScheme.Always),
// metaconfig has no breaking change from 0.13.0 to 0.14.0
"org.scalameta" % "metaconfig-core_2.12" % VersionScheme.Always,
"org.scalameta" % "metaconfig-core_2.13" % VersionScheme.Always,
"org.scalameta" % "metaconfig-pprint_2.12" % VersionScheme.Always,
"org.scalameta" % "metaconfig-pprint_2.13" % VersionScheme.Always,
"org.scalameta" % "metaconfig-typesafe-config_2.12" % VersionScheme.Always,
"org.scalameta" % "metaconfig-typesafe-config_2.13" % VersionScheme.Always
)
)

override def projectSettings: Seq[Def.Setting[_]] = List(
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
addSbtPlugin("com.github.sbt" % "sbt-ghpages" % "0.8.0")
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.1")
24 changes: 12 additions & 12 deletions scalafix-cli/src/main/scala/scalafix/internal/v1/Args.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,23 @@ case class Args(

// With a --triggered flag, looking for settings in triggered block first, and fallback to standard settings.
def maybeOverlaidConfWithTriggered(base: Conf): Conf =
if (triggered)
ScalafixConfOps.overlay(base, "triggered")
else
base
if (triggered) {
val triggeredOverlay = ConfGet
.getOrOK(base, "triggered" :: Nil, Configured.ok, Conf.Obj.empty)
.getOrElse(Conf.Obj.empty)
ConfOps.merge(base, triggeredOverlay)
} else base

def rulesConf(base: () => Conf): Conf = {
if (rules.isEmpty) {
val rulesInConf =
ConfGet.getKey(
ConfGet
.getOrOK(
maybeOverlaidConfWithTriggered(base()),
"rules" :: "rule" :: Nil
"rules" :: "rule" :: Nil,
Configured.ok,
Conf.Lst(Nil)
)

rulesInConf match {
case Some(c) => c
case _ => Conf.Lst(Nil)
}
.getOrElse(Conf.Lst(Nil))
} else {
Conf.Lst(rules.map(Conf.fromString))
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ object MetaconfigOps {
def getKey[T](conf: Conf.Obj, path: String, extraNames: String*)(implicit
ev: ConfDecoder[T]
): Configured[T] = {
ConfGet.getKey(conf, path +: extraNames) match {
case Some(value) => ev.read(value)
case None => ConfError.missingField(conf, path).notOk
}
ConfGet.getOrElse(
value => ev.read(value),
ConfError.missingField(conf, path).notOk
)(conf, path +: extraNames)
}

implicit class XtensionMetaconfigInputToMeta(input: Input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,9 @@ object OrganizeImports {
): Configured[OrganizeImportsConfig] = {
val preset = OrganizeImportsConfig.presets(ruleConf.preset)
val presetConf = ConfEncoder[OrganizeImportsConfig].write(preset)
val userConf =
ConfGet.getKey(conf, "OrganizeImports" :: Nil).getOrElse(Conf.Obj.empty)
val userConf = ConfGet
.getOrOK(conf, "OrganizeImports" :: Nil, Configured.ok, Conf.Obj.empty)
.getOrElse(Conf.Obj.empty)
val mergedConf = ConfOps.merge(presetConf, userConf)
ConfDecoder[OrganizeImportsConfig].read(mergedConf)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import scala.meta._
import scala.meta.internal.inputs.XtensionInput

import metaconfig.Conf
import metaconfig.ConfError
import metaconfig.Configured
import metaconfig.internal.ConfGet
import metaconfig.typesafeconfig.typesafeConfigMetaconfigParser
import scalafix.internal.config.ScalafixConfig
Expand Down Expand Up @@ -45,7 +47,14 @@ object SemanticRuleSuite {
for {
conf <- Try(Conf.parseString("comment", syntax)).toOption
.flatMap(_.toEither.toOption)
rulesConf <- ConfGet.getKey(conf, "rules" :: "rule" :: Nil)
rulesConf <-
ConfGet
.getOrElse(
Configured.ok,
ConfError.message("").notOk
)(conf, "rules" :: "rule" :: Nil)
.toEither
.toOption
scalafixConfig <- conf.as[ScalafixConfig].toEither.toOption
} yield (comment, conf, rulesConf, scalafixConfig)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalafix.tests.config
import scala.meta.io.AbsolutePath

import metaconfig.Conf
import metaconfig.Configured
import metaconfig.internal.ConfGet
import metaconfig.typesafeconfig.typesafeConfigMetaconfigParser
import scalafix.internal.config.ScalaVersion
Expand Down Expand Up @@ -46,7 +47,9 @@ class ArgsSuite extends munit.FunSuite {

val merged = args.maybeOverlaidConfWithTriggered(givenConf)

val disableSyntaxRule = ConfGet.getKey(merged, "DisableSyntax" :: Nil).get
val disableSyntaxRule = ConfGet
.getOrOK(merged, "DisableSyntax" :: Nil, Configured.ok, Conf.Obj.empty)
.get

val expected =
Conf.Obj("noVars" -> Conf.Bool(true), "noThrows" -> Conf.Bool(true))
Expand All @@ -64,7 +67,9 @@ class ArgsSuite extends munit.FunSuite {

val merged = args.maybeOverlaidConfWithTriggered(givenConf)

val disableSyntaxRule = ConfGet.getKey(merged, "DisableSyntax" :: Nil).get
val disableSyntaxRule = ConfGet
.getOrOK(merged, "DisableSyntax" :: Nil, Configured.ok, Conf.Obj.empty)
.get

val expected =
Conf.Obj(
Expand Down

0 comments on commit ec767bb

Please sign in to comment.