Skip to content

Commit fb546a5

Browse files
committed
Update Scala version
1 parent 727b8f5 commit fb546a5

File tree

9 files changed

+47
-12
lines changed

9 files changed

+47
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Fix some anomaly checking with `additionalProperties`
1616

1717
### Changed
18+
- Update to Scala 2.13.14
1819
- Update to Java 11
1920
- Change base image for Docker container
2021
- Set build timestamp for reproducible builds

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Dependencies._
22
import com.typesafe.sbt.packager.docker._
33
import xerial.sbt.Sonatype._
44

5-
ThisBuild / scalaVersion := "2.13.10"
5+
ThisBuild / scalaVersion := "2.13.14"
66
ThisBuild / versionScheme := Some("early-semver")
77
ThisBuild / organization := "io.github.dataunitylab"
88
ThisBuild / organizationName := "Rochester Institute of Technology"

sbtx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ set -o pipefail
3737
declare -r sbt_release_version="1.8.2"
3838
declare -r sbt_unreleased_version="1.8.2"
3939

40-
declare -r latest_213="2.13.10"
40+
declare -r latest_213="2.13.14"
4141
declare -r latest_212="2.12.17"
4242
declare -r latest_211="2.11.12"
4343
declare -r latest_210="2.10.7"

src/main/scala/io/github/dataunitylab/jsonoid/discovery/schemas/ArraySchema.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ final case class ItemTypeProperty(
450450
itemType match {
451451
case Left(singleType) =>
452452
arr.zipWithIndex.flatMap { case (schema, index) =>
453-
singleType.collectAnomalies(schema, f"${path}[$index]")
453+
singleType.collectAnomalies(schema, f"${path}[${index.toString}]")
454454
}
455455

456456
case Right(typeList) =>
@@ -465,7 +465,8 @@ final case class ItemTypeProperty(
465465
} else {
466466
typeList.zip(arr).zipWithIndex.flatMap {
467467
case ((schema, arrayValue), index) =>
468-
schema.collectAnomalies(arrayValue, f"${path}[$index]")
468+
schema
469+
.collectAnomalies(arrayValue, f"${path}[${index.toString}]")
469470
}
470471
}
471472
}

src/main/scala/io/github/dataunitylab/jsonoid/discovery/schemas/JsonSchema.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scala.reflect.ClassTag
77

88
import org.json4s.JsonDSL._
99
import org.json4s._
10+
import org.json4s.jackson.JsonMethods._
1011

1112
import Helpers._
1213
import utils.JsonPointer
@@ -515,7 +516,13 @@ trait JsonSchema[T] {
515516
if (isValidType(value))
516517
properties.flatMap(_.collectAnomalies(value, path)(p, tag)).toSeq
517518
else
518-
Seq(Anomaly(path, f"${value} has wrong type", AnomalyLevel.Fatal))
519+
Seq(
520+
Anomaly(
521+
path,
522+
f"${compact(render(value))} has wrong type",
523+
AnomalyLevel.Fatal
524+
)
525+
)
519526
}
520527

521528
/** Update a schema to only include a specific set of properties.

src/main/scala/io/github/dataunitylab/jsonoid/discovery/schemas/NullSchema.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package schemas
44
import scala.reflect.ClassTag
55

66
import org.json4s._
7+
import org.json4s.jackson.JsonMethods._
78

89
import Helpers._
910

@@ -61,6 +62,12 @@ final case class NullSchema(
6162
//
6263
// Note that we override this behaviour in [[ProductSchema]] since
6364
// there we are explicitly expecting some non-null value
64-
Seq(Anomaly(path, f"${value} is not null", AnomalyLevel.Info))
65+
Seq(
66+
Anomaly(
67+
path,
68+
f"${compact(render(value))} is not null",
69+
AnomalyLevel.Info
70+
)
71+
)
6572
}
6673
}

src/main/scala/io/github/dataunitylab/jsonoid/discovery/schemas/ProductSchema.scala

+23-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scala.reflect.ClassTag
77

88
import org.json4s.JsonDSL._
99
import org.json4s._
10+
import org.json4s.jackson.JsonMethods._
1011

1112
import Helpers._
1213
import utils.JsonPointer
@@ -421,7 +422,13 @@ final case class ProductSchemaTypesProperty(
421422
Seq.empty
422423
} else {
423424
val maxLevel = maxAnomalyLevels.flatten.max
424-
Seq(Anomaly(path, f"failed match for ${value} in schema", maxLevel))
425+
Seq(
426+
Anomaly(
427+
path,
428+
f"failed match for ${compact(render(value))} in schema",
429+
maxLevel
430+
)
431+
)
425432
}
426433

427434
// At least one schema must have no anomalies or only info level
@@ -434,7 +441,13 @@ final case class ProductSchemaTypesProperty(
434441
Seq.empty
435442
} else {
436443
val maxLevel = maxAnomalyLevels.flatten.max
437-
Seq(Anomaly(path, f"failed match for ${value} in schema", maxLevel))
444+
Seq(
445+
Anomaly(
446+
path,
447+
f"failed match for ${compact(render(value))} in schema",
448+
maxLevel
449+
)
450+
)
438451
}
439452

440453
// Info anomalies are fine in multiple schemas
@@ -447,12 +460,18 @@ final case class ProductSchemaTypesProperty(
447460
// We take the lowest anomaly level from each schema
448461
// since this is the schema with the closest match
449462
val minAnomalyLevel = maxAnomalyLevels.flatten.min
450-
Seq(Anomaly(path, f"no matches found for ${value}", minAnomalyLevel))
463+
Seq(
464+
Anomaly(
465+
path,
466+
f"no matches found for ${compact(render(value))}",
467+
minAnomalyLevel
468+
)
469+
)
451470
} else {
452471
Seq(
453472
Anomaly(
454473
path,
455-
f"multiple matches found for ${value}",
474+
f"multiple matches found for ${compact(render(value))}",
456475
AnomalyLevel.Fatal
457476
)
458477
)

src/test/scala/io/github/dataunitylab/jsonoid/discovery/schemas/ObjectSchemaSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ObjectSchemaSpec extends UnitSpec with ScalaCheckPropertyChecks {
111111
it should "pass through anomalies from matches schemas" in {
112112
PatternTypesProperty(Map("^foo.*".r -> NumberSchema(3)))
113113
.collectAnomalies(JObject(List(("foobar", JBool(true))))) shouldEqual Seq(
114-
Anomaly("$.foobar", "JBool(true) has wrong type", AnomalyLevel.Fatal)
114+
Anomaly("$.foobar", "true has wrong type", AnomalyLevel.Fatal)
115115
)
116116
}
117117

src/test/scala/io/github/dataunitylab/jsonoid/discovery/transformers/DisjointObjectTransformerSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import schemas._
66
class DisjointObjectTransformerSpec extends UnitSpec {
77
behavior of "DisjointObjectTransformer"
88

9-
implicit val propSet = PropertySets.AllProperties
9+
implicit val propSet: PropertySet = PropertySets.AllProperties
1010

1111
it should "replace disjoint objects with a product schema" in {
1212
val obj1 =

0 commit comments

Comments
 (0)