Skip to content

Commit 52e226f

Browse files
committed
Scala updates.
1 parent 89f3e3b commit 52e226f

File tree

15 files changed

+51
-30
lines changed

15 files changed

+51
-30
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id 'com.diffplug.spotless' version '6.11.0' apply false
3-
id 'cz.augi.gradle.wartremover' version '0.16.1' apply false
43
id 'info.solidsoft.pitest' version '1.9.0' apply false
54
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
65
id 'me.champeau.jmh' version '0.6.8' apply false

gradle/libs.versions.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[versions]
22
errorprone = '2.10.0'
33
jackson = '2.13.4'
4-
scala212 = '2.12.15'
5-
scala213 = '2.13.8'
4+
scala212 = '2.12.17'
5+
scala213 = '2.13.9'
66
scala3 = '3.2.0'
77
scalatest = '3.2.13'
88
scalaxml = '2.1.0'
9+
wartremover = '3.0.6'
910

1011
[libraries]
1112
assertj = 'org.assertj:assertj-core:3.23.1'
@@ -37,6 +38,9 @@ scalatest-shouldmatchers-v212 = { module = 'org.scalatest:scalatest-shouldmatche
3738
scalatest-shouldmatchers-v213 = { module = 'org.scalatest:scalatest-shouldmatchers_2.13', version.ref = 'scalatest' }
3839
scalatest-shouldmatchers-v3 = { module = 'org.scalatest:scalatest-shouldmatchers_3', version.ref = 'scalatest' }
3940
scalatest-junit-runner = 'co.helmethair:scalatest-junit-runner:0.1.12'
41+
wartremover-v212 = { module = 'org.wartremover:wartremover_2.12', version.ref = 'wartremover' }
42+
wartremover-v213 = { module = 'org.wartremover:wartremover_2.13', version.ref = 'wartremover' }
43+
wartremover-v3 = { module = 'org.wartremover:wartremover_3', version.ref = 'wartremover' }
4044
xom = 'xom:xom:1.3.8'
4145

4246
[bundles]

xpath-to-xml-scala/build-2.12.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
ext.moduleName = 'com.github.simych.xpath.scala'
22

33
apply plugin: 'scala'
4-
apply plugin: 'cz.augi.gradle.wartremover'
54

65
buildDir = 'build-2.12'
76

@@ -20,6 +19,8 @@ dependencies {
2019
implementation libs.scala.reflect.v212
2120
implementation libs.scala.xml.v212
2221

22+
scalaCompilerPlugins libs.wartremover.v212
23+
2324
testImplementation project(':xpath-to-xml-test')
2425
testImplementation libs.bundles.scalatest.v212
2526
}
@@ -45,10 +46,6 @@ scaladoc {
4546
}
4647
}
4748

48-
wartremover {
49-
warningWarts -= ['IsInstanceOf', 'Null', 'Throw', 'Var']
50-
}
51-
5249
tasks.withType(ScalaCompile) {
5350
scalaCompileOptions.with {
5451
deprecation = true
@@ -87,6 +84,7 @@ tasks.withType(ScalaCompile) {
8784
'-opt:l:method',
8885
'-opt:l:inline',
8986
'-opt-inline-from:com.github.simy4.xpath.scala.navigator.**,com.github.simy4.xpath.scala.syntax.**',
87+
'-P:wartremover:only-warn-traverser:org.wartremover.warts.Unsafe',
9088
]
9189
if (JavaVersion.current().isJava9Compatible()) {
9290
additionalParameters << '-release' << '8'

xpath-to-xml-scala/build-2.13.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
ext.moduleName = 'com.github.simych.xpath.scala'
22

33
apply plugin: 'scala'
4-
apply plugin: 'cz.augi.gradle.wartremover'
54

65
buildDir = 'build-2.13'
76

@@ -20,6 +19,8 @@ dependencies {
2019
implementation libs.scala.reflect.v213
2120
implementation libs.scala.xml.v213
2221

22+
scalaCompilerPlugins libs.wartremover.v213
23+
2324
testImplementation project(':xpath-to-xml-test')
2425
testImplementation libs.bundles.scalatest.v213
2526
}
@@ -45,10 +46,6 @@ scaladoc {
4546
}
4647
}
4748

48-
wartremover {
49-
warningWarts -= ['IsInstanceOf', 'Null', 'Throw', 'Var']
50-
}
51-
5249
tasks.withType(ScalaCompile) {
5350
scalaCompileOptions.with {
5451
deprecation = true
@@ -81,10 +78,10 @@ tasks.withType(ScalaCompile) {
8178
'-Wdead-code', // Warn when dead code is identified.
8279
'-Wnumeric-widen', // Warn when numerics are widened.
8380
'-Xsource:3', // Turn on future language features.
84-
'-target:jvm-1.8',
8581
'-opt:l:method',
8682
'-opt:l:inline',
8783
'-opt-inline-from:com.github.simy4.xpath.scala.navigator.**,com.github.simy4.xpath.scala.syntax.**',
84+
'-P:wartremover:only-warn-traverser:org.wartremover.warts.Unsafe',
8885
]
8986
if (JavaVersion.current().isJava9Compatible()) {
9087
additionalParameters << '-release' << '8'

xpath-to-xml-scala/build-3.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ dependencies {
1919
implementation libs.scala.library.v3
2020
implementation libs.scala.xml.v3
2121

22+
scalaCompilerPlugins libs.wartremover.v3
23+
2224
testImplementation project(':xpath-to-xml-test')
2325
testImplementation libs.bundles.scalatest.v3
2426
}
@@ -46,6 +48,7 @@ tasks.withType(ScalaCompile) {
4648
'-language:macros,implicitConversions',
4749
'-Xfatal-warnings', // Fail the compilation if there are any warnings.
4850
'-source:3.2', // Turn on future language features.
51+
'-P:wartremover:only-warn-traverser:org.wartremover.warts.Unsafe',
4952
]
5053
if (JavaVersion.current().isJava9Compatible()) {
5154
additionalParameters << '-release' << '8'

xpath-to-xml-scala/src/jmh/scala/com/github/simy4/xpath/ScalaXmlBuilderBenchmark.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import javax.xml.namespace.NamespaceContext
2525

2626
@BenchmarkMode(Array(Mode.Throughput))
2727
@State(Scope.Benchmark)
28+
@SuppressWarnings(Array("org.wartremover.warts.Null", "org.wartremover.warts.Var"))
2829
class ScalaXmlBuilderBenchmark {
2930

3031
@Param(Array("simple", "ns-simple", "attr", "special"))

xpath-to-xml-scala/src/main/scala-2-/com/github/simy4/xpath/scala/xpath/XPathLiteral.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class XPathLiteral(private val sc: StringContext) extends AnyVal {
2525
def xpath(args: Any*): Expr = macro XPathLiteral.xpathImpl
2626
}
2727

28+
@SuppressWarnings(Array("org.wartremover.warts.Null"))
2829
object XPathLiteral {
2930
def xpathImpl(c: blackbox.Context)(args: c.Expr[Any]*): c.Expr[Expr] = {
3031
import c.universe._

xpath-to-xml-scala/src/main/scala-3+/com/github/simy4/xpath/scala/xpath/XPathLiteral.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import javax.xml.xpath.XPathExpressionException
2323
import scala.quoted.{ quotes, Expr, Exprs, Quotes, Varargs }
2424

2525
object XPathLiteral:
26+
@SuppressWarnings(Array("org.wartremover.warts.AsInstanceOf", "org.wartremover.warts.Null", "org.wartremover.warts.IterableOps"))
2627
def xpathImpl(sc: Expr[StringContext])(using Quotes): Expr[JExpr] =
2728
import quotes.reflect.report
2829
sc match

xpath-to-xml-scala/src/main/scala/com/github/simy4/xpath/scala/impl/ToXmlElemOps.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import javax.xml.namespace.NamespaceContext
2222
import _root_.scala.collection.{ Iterable, Map }
2323
import _root_.scala.xml.Elem
2424

25+
@SuppressWarnings(Array("org.wartremover.warts.Null"))
2526
trait ToXmlElemOps {
2627
@SuppressWarnings(Array("org.wartremover.warts.DefaultArguments"))
2728
implicit def toXmlElemOps(elem: Elem)(implicit namespaceContext: NamespaceContext = null): XmlElemOps =

xpath-to-xml-scala/src/main/scala/com/github/simy4/xpath/scala/navigator/ScalaXmlNavigator.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import xml.{ Attribute => XmlAttribute, Elem, Null, Text }
2121

2222
import javax.xml.namespace.QName
2323

24+
@SuppressWarnings(Array("org.wartremover.warts.Throw"))
2425
class ScalaXmlNavigator(override val root: Root) extends Navigator[ScalaXmlNode] with scala.compat.Converters {
2526
override def parentOf(node: ScalaXmlNode): ScalaXmlNode = node.parent
2627
override def elementsOf(parent: ScalaXmlNode): java.lang.Iterable[_ <: ScalaXmlNode] = parent.elements
@@ -49,6 +50,7 @@ class ScalaXmlNavigator(override val root: Root) extends Navigator[ScalaXmlNode]
4950
case _ =>
5051
throw new XmlBuilderException(s"Unable to create element for ${parent.toString}")
5152
}
53+
@SuppressWarnings(Array("org.wartremover.warts.IsInstanceOf"))
5254
@throws[XmlBuilderException]("If unable to set text to given node")
5355
override def setText(node: ScalaXmlNode, text: String): Unit =
5456
node match {

0 commit comments

Comments
 (0)