Skip to content

Commit ec767bb

Browse files
authored
Merge pull request #2144 from scalacenter/update/mdoc-2.6.2
Update mdoc to 2.6.2 & metaconfig to 0.14.0
2 parents 8668af5 + 7166586 commit ec767bb

File tree

10 files changed

+53
-52
lines changed

10 files changed

+53
-52
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ lazy val docs = projectMatrix
448448
scalacOptions += "-Wconf:msg='match may not be exhaustive':s", // silence exhaustive pattern matching warning for documentation
449449
scalacOptions += "-Xfatal-warnings",
450450
mdoc := (Compile / run).evaluated,
451-
libraryDependencies += metaconfigDoc,
451+
libraryDependencies += scalatags,
452452
dependencyOverrides += scalametaFor3Use2_13 // force eviction of mdoc transitive dependency
453453
)
454454
.defaultAxes(VirtualAxis.jvm)

project/Dependencies.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ object Dependencies {
1717
val commontTextV = "1.13.0"
1818
val googleDiffV = "1.3.0"
1919
val jgitV = "5.13.3.202401111512-r"
20-
val metaconfigV = "0.13.0"
20+
val metaconfigV = "0.14.0"
2121
val nailgunV = "0.9.1"
2222
val scalaXmlV = "2.2.0"
2323
val scalametaV = "4.12.2"
24+
val scalatagsV = "0.13.1"
2425
val scalatestV = "3.2.19"
2526
val munitV = "1.0.3"
2627

@@ -32,12 +33,12 @@ object Dependencies {
3233
val googleDiff = "com.googlecode.java-diff-utils" % "diffutils" % googleDiffV
3334
val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % jgitV
3435
val metaconfig = "org.scalameta" %% "metaconfig-typesafe-config" % metaconfigV
35-
val metaconfigDoc = "org.scalameta" %% "metaconfig-docs" % metaconfigV
3636
val metacp = "org.scalameta" %% "metacp" % scalametaV
3737
val nailgunServer = "com.martiansoftware" % "nailgun-server" % nailgunV
3838
val scalaXml = "org.scala-lang.modules" %% "scala-xml" % scalaXmlV
3939
val scalametaFor3Use2_13 = "org.scalameta" %% "scalameta" % scalametaV cross CrossVersion.for3Use2_13
4040
val scalametaTeskitFor3Use2_13 = "org.scalameta" %% "testkit" % scalametaV cross CrossVersion.for3Use2_13
41+
val scalatags = "com.lihaoyi" %% "scalatags" % scalatagsV
4142
val scalatest = "org.scalatest" %% "scalatest" % scalatestV
4243
val munit = "org.scalameta" %% "munit" % munitV
4344
val semanticdbScalacCore = "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full

project/ScalafixBuild.scala

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,22 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
240240
"com.lihaoyi" %% "pprint",
241241
// https://github.com/scalacenter/scalafix/pull/1819#issuecomment-1636118496
242242
"org.scalameta" %% "fastparse-v2",
243-
"com.lihaoyi" %% "geny",
244-
// https://github.com/scalacenter/scalafix/pull/2025#issuecomment-2264188708
245-
"com.geirsson" %% "metaconfig-core",
246-
"com.geirsson" %% "metaconfig-pprint",
247-
"com.geirsson" %% "metaconfig-typesafe-config"
243+
"com.lihaoyi" %% "geny"
248244
),
249245
versionPolicyIgnoredInternalDependencyVersions :=
250246
Some("^\\d+\\.\\d+\\.\\d+\\+\\d+".r),
251247
versionScheme := Some("early-semver"),
252-
// coursier-versions always return false for the *.*.*.*-r pattern jgit uses
253-
libraryDependencySchemes += Dependencies.jgit.withRevision("always")
248+
libraryDependencySchemes ++= Seq(
249+
// coursier-versions always return false for the *.*.*.*-r pattern jgit uses
250+
Dependencies.jgit.withRevision(VersionScheme.Always),
251+
// metaconfig has no breaking change from 0.13.0 to 0.14.0
252+
"org.scalameta" % "metaconfig-core_2.12" % VersionScheme.Always,
253+
"org.scalameta" % "metaconfig-core_2.13" % VersionScheme.Always,
254+
"org.scalameta" % "metaconfig-pprint_2.12" % VersionScheme.Always,
255+
"org.scalameta" % "metaconfig-pprint_2.13" % VersionScheme.Always,
256+
"org.scalameta" % "metaconfig-typesafe-config_2.12" % VersionScheme.Always,
257+
"org.scalameta" % "metaconfig-typesafe-config_2.13" % VersionScheme.Always
258+
)
254259
)
255260

256261
override def projectSettings: Seq[Def.Setting[_]] = List(

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")
22
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
33
addSbtPlugin("com.github.sbt" % "sbt-ghpages" % "0.8.0")
44
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1")
5-
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1")
5+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.2")
66
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.2")
77
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0")
88
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.1")

scalafix-cli/src/main/scala/scalafix/internal/v1/Args.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,23 @@ case class Args(
255255

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

263265
def rulesConf(base: () => Conf): Conf = {
264266
if (rules.isEmpty) {
265-
val rulesInConf =
266-
ConfGet.getKey(
267+
ConfGet
268+
.getOrOK(
267269
maybeOverlaidConfWithTriggered(base()),
268-
"rules" :: "rule" :: Nil
270+
"rules" :: "rule" :: Nil,
271+
Configured.ok,
272+
Conf.Lst(Nil)
269273
)
270-
271-
rulesInConf match {
272-
case Some(c) => c
273-
case _ => Conf.Lst(Nil)
274-
}
274+
.getOrElse(Conf.Lst(Nil))
275275
} else {
276276
Conf.Lst(rules.map(Conf.fromString))
277277
}

scalafix-cli/src/main/scala/scalafix/internal/v1/ScalafixConfOps.scala

Lines changed: 0 additions & 20 deletions
This file was deleted.

scalafix-core/src/main/scala/scalafix/internal/config/MetaconfigOps.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ object MetaconfigOps {
3636
def getKey[T](conf: Conf.Obj, path: String, extraNames: String*)(implicit
3737
ev: ConfDecoder[T]
3838
): Configured[T] = {
39-
ConfGet.getKey(conf, path +: extraNames) match {
40-
case Some(value) => ev.read(value)
41-
case None => ConfError.missingField(conf, path).notOk
42-
}
39+
ConfGet.getOrElse(
40+
value => ev.read(value),
41+
ConfError.missingField(conf, path).notOk
42+
)(conf, path +: extraNames)
4343
}
4444

4545
implicit class XtensionMetaconfigInputToMeta(input: Input) {

scalafix-rules/src/main/scala/scalafix/internal/rule/OrganizeImports.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,9 @@ object OrganizeImports {
852852
): Configured[OrganizeImportsConfig] = {
853853
val preset = OrganizeImportsConfig.presets(ruleConf.preset)
854854
val presetConf = ConfEncoder[OrganizeImportsConfig].write(preset)
855-
val userConf =
856-
ConfGet.getKey(conf, "OrganizeImports" :: Nil).getOrElse(Conf.Obj.empty)
855+
val userConf = ConfGet
856+
.getOrOK(conf, "OrganizeImports" :: Nil, Configured.ok, Conf.Obj.empty)
857+
.getOrElse(Conf.Obj.empty)
857858
val mergedConf = ConfOps.merge(presetConf, userConf)
858859
ConfDecoder[OrganizeImportsConfig].read(mergedConf)
859860
}

scalafix-testkit/src/main/scala/scalafix/testkit/SemanticRuleSuite.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import scala.meta._
66
import scala.meta.internal.inputs.XtensionInput
77

88
import metaconfig.Conf
9+
import metaconfig.ConfError
10+
import metaconfig.Configured
911
import metaconfig.internal.ConfGet
1012
import metaconfig.typesafeconfig.typesafeConfigMetaconfigParser
1113
import scalafix.internal.config.ScalafixConfig
@@ -45,7 +47,14 @@ object SemanticRuleSuite {
4547
for {
4648
conf <- Try(Conf.parseString("comment", syntax)).toOption
4749
.flatMap(_.toEither.toOption)
48-
rulesConf <- ConfGet.getKey(conf, "rules" :: "rule" :: Nil)
50+
rulesConf <-
51+
ConfGet
52+
.getOrElse(
53+
Configured.ok,
54+
ConfError.message("").notOk
55+
)(conf, "rules" :: "rule" :: Nil)
56+
.toEither
57+
.toOption
4958
scalafixConfig <- conf.as[ScalafixConfig].toEither.toOption
5059
} yield (comment, conf, rulesConf, scalafixConfig)
5160
}

scalafix-tests/unit/src/test/scala/scalafix/tests/config/ArgsSuite.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package scalafix.tests.config
33
import scala.meta.io.AbsolutePath
44

55
import metaconfig.Conf
6+
import metaconfig.Configured
67
import metaconfig.internal.ConfGet
78
import metaconfig.typesafeconfig.typesafeConfigMetaconfigParser
89
import scalafix.internal.config.ScalaVersion
@@ -46,7 +47,9 @@ class ArgsSuite extends munit.FunSuite {
4647

4748
val merged = args.maybeOverlaidConfWithTriggered(givenConf)
4849

49-
val disableSyntaxRule = ConfGet.getKey(merged, "DisableSyntax" :: Nil).get
50+
val disableSyntaxRule = ConfGet
51+
.getOrOK(merged, "DisableSyntax" :: Nil, Configured.ok, Conf.Obj.empty)
52+
.get
5053

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

6568
val merged = args.maybeOverlaidConfWithTriggered(givenConf)
6669

67-
val disableSyntaxRule = ConfGet.getKey(merged, "DisableSyntax" :: Nil).get
70+
val disableSyntaxRule = ConfGet
71+
.getOrOK(merged, "DisableSyntax" :: Nil, Configured.ok, Conf.Obj.empty)
72+
.get
6873

6974
val expected =
7075
Conf.Obj(

0 commit comments

Comments
 (0)