Skip to content

Commit

Permalink
Fix compile warnings
Browse files Browse the repository at this point in the history
formatting
  • Loading branch information
hamnis committed Jun 13, 2024
1 parent 31ebc54 commit 37f7c69
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,29 @@ 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))
}

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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand Down

0 comments on commit 37f7c69

Please sign in to comment.