diff --git a/build.sbt b/build.sbt index 6ca9a852..0e0bbc97 100644 --- a/build.sbt +++ b/build.sbt @@ -72,8 +72,8 @@ lazy val genericExtras = crossProject(JSPlatform, JVMPlatform, NativePlatform) } else Nil ), testFrameworks := List(new TestFramework("munit.Framework")), // Override setting so Scalatest is disabled - //docMappingsApiDir := "api", - //addMappingsToSiteDir(Compile / packageDoc / mappings, docMappingsApiDir), + // docMappingsApiDir := "api", + // addMappingsToSiteDir(Compile / packageDoc / mappings, docMappingsApiDir), scalacOptions ++= { if (scalaBinaryVersion.value == "2.13") Seq("-Ymacro-annotations") else Seq.empty }, diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/AutoDerivation.scala b/generic-extras/src/main/scala/io/circe/generic/extras/AutoDerivation.scala index fb6b7dca..b45cbc0b 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/AutoDerivation.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/AutoDerivation.scala @@ -5,7 +5,6 @@ import io.circe.export.Exported import io.circe.generic.extras.decoding.ConfiguredDecoder import io.circe.generic.extras.encoding.ConfiguredAsObjectEncoder import io.circe.generic.util.macros.ExportMacros -import scala.language.experimental.macros /** * Fully automatic configurable codec derivation. diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/ConfiguredJsonCodec.scala b/generic-extras/src/main/scala/io/circe/generic/extras/ConfiguredJsonCodec.scala index b99d4925..0fcec684 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/ConfiguredJsonCodec.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/ConfiguredJsonCodec.scala @@ -1,9 +1,11 @@ package io.circe.generic.extras import io.circe.generic.util.macros.JsonCodecMacros -import scala.language.experimental.macros + +import scala.annotation.nowarn import scala.reflect.macros.blackbox +@nowarn("cat=unused") class ConfiguredJsonCodec( encodeOnly: Boolean = false, decodeOnly: Boolean = false diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/codec/EnumerationCodec.scala b/generic-extras/src/main/scala/io/circe/generic/extras/codec/EnumerationCodec.scala index 0b83f3eb..c3cfabbb 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/codec/EnumerationCodec.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/codec/EnumerationCodec.scala @@ -36,10 +36,10 @@ object EnumerationCodec { case Right(v) => Right(Inr(v)) case Left(err) => Left(err) } - case Left(err) => Left(DecodingFailure("Enumeration", c.history)) + case Left(_) => Left(DecodingFailure("Enumeration", c.history)) } def apply(a: FieldType[K, V] :+: R): Json = a match { - case Inl(l) => Json.fromString(config.transformConstructorNames(witK.value.name)) + case Inl(_) => Json.fromString(config.transformConstructorNames(witK.value.name)) case Inr(r) => codecForR(r) } } diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/codec/ReprAsObjectCodec.scala b/generic-extras/src/main/scala/io/circe/generic/extras/codec/ReprAsObjectCodec.scala index 4098338f..29fe7b0e 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/codec/ReprAsObjectCodec.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/codec/ReprAsObjectCodec.scala @@ -7,7 +7,6 @@ import io.circe.generic.extras.decoding.ReprDecoder import io.circe.generic.extras.encoding.ReprAsObjectEncoder import scala.annotation.implicitNotFound import scala.collection.immutable.Map -import scala.language.experimental.macros import shapeless.HNil /** diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/decoding/EnumerationDecoder.scala b/generic-extras/src/main/scala/io/circe/generic/extras/decoding/EnumerationDecoder.scala index 84a1ace4..f9586238 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/decoding/EnumerationDecoder.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/decoding/EnumerationDecoder.scala @@ -35,7 +35,7 @@ object EnumerationDecoder { case Right(v) => Right(Inr(v)) case Left(err) => Left(err) } - case Left(err) => Left(DecodingFailure("Enumeration", c.history)) + case Left(_) => Left(DecodingFailure("Enumeration", c.history)) } } diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ReprDecoder.scala b/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ReprDecoder.scala index 08b85bfa..888d27ca 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ReprDecoder.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ReprDecoder.scala @@ -6,7 +6,6 @@ import io.circe.Json.JNull import io.circe.generic.extras.ConfigurableDeriver import scala.annotation.implicitNotFound import scala.collection.immutable.Map -import scala.language.experimental.macros import shapeless.HNil /** @@ -51,7 +50,7 @@ abstract class ReprDecoder[A] extends Decoder[A] { case (true, Some(d: B @unchecked)) => Right(d) case (_, Some(d: B @unchecked)) => decoder.tryDecode(c) match { - case l @ Left(_) if c.focus.contains(JNull) => + case Left(_) if c.focus.contains(JNull) => Right(d) case otherwise => otherwise @@ -70,7 +69,7 @@ abstract class ReprDecoder[A] extends Decoder[A] { case (true, Some(d: B @unchecked)) => Validated.valid(d) case (_, Some(d: B @unchecked)) => decoder.tryDecodeAccumulating(c) match { - case l @ Validated.Invalid(_) if c.focus.contains(JNull) => + case Validated.Invalid(_) if c.focus.contains(JNull) => Validated.valid(d) case otherwise => otherwise diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/encoding/EnumerationEncoder.scala b/generic-extras/src/main/scala/io/circe/generic/extras/encoding/EnumerationEncoder.scala index 615a7c33..a0b62981 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/encoding/EnumerationEncoder.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/encoding/EnumerationEncoder.scala @@ -2,7 +2,8 @@ package io.circe.generic.extras.encoding import io.circe.{ Encoder, Json } import io.circe.generic.extras.Configuration -import scala.annotation.implicitNotFound + +import scala.annotation.{ implicitNotFound, nowarn } import shapeless.{ :+:, CNil, Coproduct, HNil, Inl, Inr, LabelledGeneric, Witness } import shapeless.labelled.FieldType @@ -22,12 +23,12 @@ object EnumerationEncoder { implicit def encodeEnumerationCCons[K <: Symbol, V, R <: Coproduct](implicit witK: Witness.Aux[K], - gen: LabelledGeneric.Aux[V, HNil], + @nowarn gen: LabelledGeneric.Aux[V, HNil], encodeR: EnumerationEncoder[R], config: Configuration = Configuration.default ): EnumerationEncoder[FieldType[K, V] :+: R] = new EnumerationEncoder[FieldType[K, V] :+: R] { def apply(a: FieldType[K, V] :+: R): Json = a match { - case Inl(l) => Json.fromString(config.transformConstructorNames(witK.value.name)) + case Inl(_) => Json.fromString(config.transformConstructorNames(witK.value.name)) case Inr(r) => encodeR(r) } } diff --git a/generic-extras/src/main/scala/io/circe/generic/extras/encoding/ReprAsObjectEncoder.scala b/generic-extras/src/main/scala/io/circe/generic/extras/encoding/ReprAsObjectEncoder.scala index cb601a7f..37426c6e 100644 --- a/generic-extras/src/main/scala/io/circe/generic/extras/encoding/ReprAsObjectEncoder.scala +++ b/generic-extras/src/main/scala/io/circe/generic/extras/encoding/ReprAsObjectEncoder.scala @@ -1,8 +1,8 @@ package io.circe.generic.extras.encoding + import io.circe.{ Encoder, Json, JsonObject } import io.circe.generic.extras.ConfigurableDeriver import scala.annotation.implicitNotFound -import scala.language.experimental.macros /** * An encoder for a generic representation of a case class or ADT. diff --git a/generic-extras/src/test/scala/io/circe/generic/extras/CirceSuite.scala b/generic-extras/src/test/scala/io/circe/generic/extras/CirceSuite.scala index 2872b95b..64c644f8 100644 --- a/generic-extras/src/test/scala/io/circe/generic/extras/CirceSuite.scala +++ b/generic-extras/src/test/scala/io/circe/generic/extras/CirceSuite.scala @@ -3,10 +3,8 @@ package io.circe.generic.extras import cats.instances._ import cats.syntax._ import io.circe.testing.{ ArbitraryInstances, EqInstances } -import org.typelevel.discipline.Laws -import scala.language.implicitConversions -import munit.{ DisciplineSuite, Location, ScalaCheckSuite } +import munit.DisciplineSuite /** * An opinionated stack of traits to improve consistency and reduce boilerplate in circe tests. diff --git a/generic-extras/src/test/scala/io/circe/generic/extras/ConfiguredJsonCodecSuite.scala b/generic-extras/src/test/scala/io/circe/generic/extras/ConfiguredJsonCodecSuite.scala index a8092741..cef8fc44 100644 --- a/generic-extras/src/test/scala/io/circe/generic/extras/ConfiguredJsonCodecSuite.scala +++ b/generic-extras/src/test/scala/io/circe/generic/extras/ConfiguredJsonCodecSuite.scala @@ -7,8 +7,6 @@ import io.circe.testing.CodecTests import org.scalacheck.Prop.forAll import org.scalacheck.{ Arbitrary, Gen } -import scala.Console.in - object ConfiguredJsonCodecSuite { implicit val customConfig: Configuration = Configuration.default.withSnakeCaseMemberNames.withDefaults.withDiscriminator("type").withSnakeCaseConstructorNames diff --git a/generic-extras/src/test/scala/io/circe/generic/extras/EnumerationSemiautoDerivedSuite.scala b/generic-extras/src/test/scala/io/circe/generic/extras/EnumerationSemiautoDerivedSuite.scala index aff5773c..22336fde 100644 --- a/generic-extras/src/test/scala/io/circe/generic/extras/EnumerationSemiautoDerivedSuite.scala +++ b/generic-extras/src/test/scala/io/circe/generic/extras/EnumerationSemiautoDerivedSuite.scala @@ -29,11 +29,13 @@ class EnumerationSemiautoDerivedSuite extends CirceSuite { test("deriveEnumerationDecoder should not compile on an ADT with case classes") { implicit val config: Configuration = Configuration.default + val _ = config illTyped("deriveEnumerationDecoder[ExtendedCardinalDirection]") } - test("it should respect Configuration") { + test("it should respect Configuration snake-case") { implicit val config: Configuration = Configuration.default.withSnakeCaseConstructorNames + val _ = config val decodeMary = deriveEnumerationDecoder[Mary] val expected = json""""little_lamb"""" assert(decodeMary.decodeJson(expected) === Right(LittleLamb)) @@ -41,13 +43,15 @@ class EnumerationSemiautoDerivedSuite extends CirceSuite { test("deriveEnumerationEncoder should not compile on an ADT with case classes") { implicit val config: Configuration = Configuration.default + val _ = config illTyped("deriveEnumerationEncoder[ExtendedCardinalDirection]") } - test("it should respect Configuration") { - implicit val config: Configuration = Configuration.default.withSnakeCaseConstructorNames + test("it should respect Configuration kebab-case") { + implicit val config: Configuration = Configuration.default.withKebabCaseConstructorNames + val _ = config val encodeMary = deriveEnumerationEncoder[Mary] - val expected = json""""little_lamb"""" + val expected = json""""little-lamb"""" assert(encodeMary(LittleLamb) === expected) } } diff --git a/generic-extras/src/test/scala/io/circe/generic/extras/UnwrappedSemiautoDerivedSuite.scala b/generic-extras/src/test/scala/io/circe/generic/extras/UnwrappedSemiautoDerivedSuite.scala index 9898d312..d3df583a 100644 --- a/generic-extras/src/test/scala/io/circe/generic/extras/UnwrappedSemiautoDerivedSuite.scala +++ b/generic-extras/src/test/scala/io/circe/generic/extras/UnwrappedSemiautoDerivedSuite.scala @@ -49,7 +49,7 @@ class UnwrappedSemiautoDerivedSuite extends CirceSuite { } property("it should fail decoding incompatible JSON") { - forAll { (i: Int, s: String) => + forAll { (i: Int) => val json = Json.fromInt(i) val expected = Left(DecodingFailure(DecodingFailure.Reason.WrongTypeExpectation("string", json), List()))