Skip to content

Commit b5b86bd

Browse files
committed
Started checking issue623
1 parent b7d868f commit b5b86bd

11 files changed

Lines changed: 97 additions & 39 deletions

File tree

build.sbt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
lazy val scala212 = "2.12.17"
2-
lazy val scala213 = "2.13.10"
3-
lazy val scala3 = "3.2.1"
1+
lazy val scala212 = "2.12.20"
2+
lazy val scala213 = "2.13.15"
3+
lazy val scala3 = "3.6.3"
44
lazy val supportedScalaVersions = List(
5-
scala3,
65
scala213,
6+
scala3,
77
scala212
88
)
99

10-
val Java11 = JavaSpec.temurin("11")
10+
val Java11 = JavaSpec.temurin("11")
1111

1212
lazy val srdfVersion = "0.1.125"
1313
lazy val utilsVersion = "0.2.25"
@@ -19,7 +19,7 @@ lazy val catsVersion = "2.9.0"
1919
lazy val catsEffectVersion = "3.4.4"
2020
lazy val circeVersion = "0.14.2"
2121
lazy val commonsTextVersion = "1.8"
22-
lazy val declineVersion = "2.4.1"
22+
lazy val declineVersion = "2.5.0"
2323
lazy val fansiVersion = "0.3.0"
2424
lazy val fs2Version = "3.4.0"
2525
lazy val jenaVersion = "4.3.2"
@@ -73,7 +73,6 @@ lazy val wdtkUtil = "org.wikidata.wdtk" % "wdtk-util" % wikidataToolkitVersion
7373
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % scalacheckVersion
7474
lazy val typesafeConfig = "com.typesafe" % "config" % typesafeConfigVersion
7575

76-
7776
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
7877
lazy val scalaLogging =
7978
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion
@@ -142,8 +141,8 @@ lazy val shexs = project
142141
catsEffect,
143142
decline,
144143
declineEffect,
145-
slf4jAPI,
146-
slf4jSimple,
144+
// slf4jAPI,
145+
// slf4jSimple,
147146
srdf,
148147
srdf4j,
149148
srdfJena,
@@ -252,7 +251,7 @@ lazy val wshex = project
252251
.settings(
253252
crossScalaVersions := supportedScalaVersions,
254253
libraryDependencies ++= Seq(
255-
utils,
254+
utils,
256255
catsCore,
257256
catsKernel,
258257
circeCore,
@@ -269,7 +268,7 @@ lazy val wshex = project
269268
scalaCollCompat,
270269
srdfJena,
271270
munit % Test,
272-
munitEffect % Test,
271+
munitEffect % Test
273272
),
274273
testFrameworks += new TestFramework("munit.Framework")
275274
)
@@ -580,6 +579,8 @@ lazy val commonSettings = compilationSettings ++ sharedDependencies ++ Seq(
580579
email = "jelabra@gmail.com",
581580
url = url("https://weso.labra.es")
582581
)
583-
),
584-
libraryDependencies += compilerPlugin("com.github.ghik" % "zerowaste" % "0.2.1" cross CrossVersion.full)
582+
)
583+
/*libraryDependencies += compilerPlugin(
584+
("com.github.ghik" % "zerowaste" % "1.0.0").cross(CrossVersion.full)
585+
)*/
585586
) ++ warnUnusedImport

examples/separation.shex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
prefix : <http://example.org/>
2+
3+
# Separation test
4+
:S {
5+
:p @:S +
6+
}
7+
8+
:S1 NOT @:S

modules/shex/src/main/scala/es/weso/shex/Dependencies.scala

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ object Dependencies {
2525
depGraph(schema).map(_.negCycles)
2626

2727
def oddNegCycles(schema: Schema): ES[Set[Set[(ShapeLabel, ShapeLabel)]]] =
28-
depGraph(schema).map(_.oddNegCycles)
29-
/* for {
28+
// depGraph(schema).map(_.oddNegCycles)
29+
for {
3030
dg <- depGraph(schema)
31-
negCycles = dg.negCycles.filter { nc => dg.countNegLinks(nc) % 2 == 1 }
32-
} yield negCycles */
31+
_ <- { println(s"Dependency graph: $dg"); Right(()) }
32+
negCycles = dg.negCycles.filter(nc => dg.countNegLinks(nc) % 2 == 1)
33+
} yield negCycles
3334

3435
/** Returns the dependency graph of a schema
3536
*
@@ -42,7 +43,7 @@ object Dependencies {
4243
case None => emptyGraph
4344
case Some(shapes) => shapes.foldRight(emptyGraph)(addDependency(schema))
4445
}
45-
// println(s"Dependency graph: $r")
46+
println(s"Dependency graph: $r")
4647
r
4748
}
4849

@@ -65,8 +66,15 @@ object Dependencies {
6566
def getLabel(se: ShapeExpr): ES[ShapeLabel] =
6667
Either.fromOption(se.id, s"Shape $se has no label")
6768

68-
def dependencies(schema: Schema, shape: ShapeExpr, source: ShapeLabel, posNeg: PosNeg): ES[Deps] =
69-
// println(s"Calculating dependencies of shape $shape with source label $source and posNeg $posNeg")
69+
def dependencies(
70+
schema: Schema,
71+
shape: ShapeExpr,
72+
source: ShapeLabel,
73+
posNeg: PosNeg
74+
): ES[Deps] = {
75+
println(
76+
s"Calculating dependencies of shape $shape with source label $source and posNeg $posNeg"
77+
)
7078
shape match {
7179
case s: ShapeAnd =>
7280
s.shapeExprs.map(dependencies(schema, _, source, posNeg)).sequence[ES, Deps].map(_.flatten)
@@ -101,6 +109,7 @@ object Dependencies {
101109
case _: ShapeExternal => noDeps
102110
case sd: ShapeDecl => dependencies(schema, sd.shapeExpr, source, posNeg)
103111
}
112+
}
104113

105114
def dependenciesTripleExpr(
106115
schema: Schema,

modules/shex/src/main/scala/es/weso/shex/Schema.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,22 @@ case class Schema(
130130
_ <- shapesMap.keySet.toList.map(lbl => checkShapeLabel(lbl)).sequence
131131
} yield (())
132132

133-
private lazy val checkOddNegCycles: Either[String, Unit] =
134-
// println(s"OddNegCycles: $oddNegCycles")
133+
private lazy val checkOddNegCycles: Either[String, Unit] = {
134+
println(s"OddNegCycles: $oddNegCycles")
135135
oddNegCycles match {
136136
case Left(e) => Left(e)
137137
case Right(cs) =>
138138
if (cs.isEmpty) Right(())
139139
else
140140
Left(s"Negative cycles: ${showCycles(oddNegCycles)}")
141141
}
142+
}
142143

143144
lazy val wellFormed: Either[String, Unit] = for {
144145
_ <- checkOddNegCycles
145-
// _ <- { println(s"Passed checkOddNegCycles..."); Right(())}
146+
_ <- { println(s"Passed checkOddNegCycles..."); Right(()) }
146147
_ <- checkBadShapeLabels
147-
// _ <- { println(s"Passed checkBadShapeLabels..."); Right(())}
148+
_ <- { println(s"Passed checkBadShapeLabels..."); Right(()) }
148149
} yield (())
149150

150151
def relativize(maybeBase: Option[IRI]): Schema = maybeBase match {
@@ -161,7 +162,7 @@ case class Schema(
161162
def resolve(base: Option[IRI], verbose: VerboseLevel): IO[ResolvedSchema] =
162163
ResolvedSchema.resolve(this, base, verbose)
163164

164-
def withId(iri: IRI): Schema = this.copy(id = iri)
165+
def withId(iri: IRI): Schema = this.copy(id = iri)
165166

166167
def withShapes(ses: ShapeExpr*): Schema = this.copy(shapes = ses.toList.some)
167168

@@ -177,7 +178,6 @@ object Schema {
177178
def emptyWithId(iri: IRI): Schema =
178179
Schema.empty.withId(iri)
179180

180-
181181
def fromIRI(
182182
i: IRI,
183183
base: Option[IRI],

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.8.0
1+
sbt.version=1.10.11

project/metals.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
// This file enables sbt-bloop to create bloop config files.
55

6-
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.17")
6+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.9")
77

88
// format: on

project/plugins.sbt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
2-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
1+
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.25.0")
2+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.0")
33
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
44
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
5-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
6-
// addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.0")
7-
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
5+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
6+
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.1.0")
7+
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.1")
88
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2")
99
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.5")
10-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
10+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.1")
1111
addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.8.3")
12-
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
12+
addSbtPlugin("com.github.sbt" % "sbt-site-asciidoctor" % "1.5.0")
1313
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")

project/project/metals.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
// This file enables sbt-bloop to create bloop config files.
55

6-
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.17")
6+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.9")
77

88
// format: on

project/project/project/metals.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
// This file enables sbt-bloop to create bloop config files.
55

6-
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.17")
6+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.9")
77

88
// format: on

src/main/scala/es/weso/shexs/Main.scala

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import es.weso.shex.validator.Validator
1010
import es.weso.shextest.manifest.{Validate => _, _}
1111
import com.monovore.decline._
1212
import com.monovore.decline.effect._
13+
import com.typesafe.scalalogging.LazyLogging
14+
1315
// import buildinfo._
1416
import java.nio.file.Path
1517
import es.weso.shapepath.schemamappings.SchemaMappings
@@ -45,7 +47,8 @@ object Main
4547
name = "shex-s",
4648
header = "ShEx-Scala command line tool",
4749
version = "0.2.2" // BuildInfo.version
48-
) {
50+
)
51+
with LazyLogging {
4952

5053
lazy val mappingOpt = Opts.option[Path](
5154
"mapping",
@@ -72,7 +75,31 @@ object Main
7275
if (verbose) IO.println(msg)
7376
else IO(())
7477

75-
override def main: Opts[IO[ExitCode]] =
78+
private def disable_logs(): Unit = {
79+
// The following code is needed to remove extra logging from Jena
80+
import org.apache.jena.riot.system.stream.JenaIOEnvironment
81+
import org.apache.jena.riot.system.stream.LocationMapper
82+
val mapper: LocationMapper = new LocationMapper()
83+
JenaIOEnvironment.setGlobalLocationMapper(mapper)
84+
85+
// Force logging level to None
86+
val log: ch.qos.logback.classic.Logger =
87+
logger.underlying.asInstanceOf[ch.qos.logback.classic.Logger]
88+
log.getName()
89+
import org.slf4j.LoggerFactory
90+
import ch.qos.logback.classic._
91+
val es_weso_log: ch.qos.logback.classic.Logger =
92+
LoggerFactory.getLogger("es.weso").asInstanceOf[ch.qos.logback.classic.Logger]
93+
val org_log: ch.qos.logback.classic.Logger =
94+
LoggerFactory.getLogger("org").asInstanceOf[ch.qos.logback.classic.Logger]
95+
org_log.setLevel(Level.OFF)
96+
es_weso_log.setLevel(Level.OFF)
97+
log.setLevel(Level.OFF)
98+
99+
}
100+
101+
override def main: Opts[IO[ExitCode]] = {
102+
disable_logs()
76103
schemaMappingCommand
77104
.orElse(Validate.validateCommand)
78105
.orElse(shapePathValidateCommand)
@@ -90,6 +117,7 @@ object Main
90117
.map(
91118
_.handleErrorWith(infoError)
92119
)
120+
}
93121

94122
def infoError(err: Throwable): IO[ExitCode] =
95123
IO.println(s"Error ${err.getLocalizedMessage()}") *> IO(ExitCode.Error)

0 commit comments

Comments
 (0)