Skip to content

Commit

Permalink
Update metaconfig-typesafe-config to 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Dec 21, 2024
1 parent 5c790f1 commit 7166586
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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"
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
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 7166586

Please sign in to comment.