This is an automated email from the ASF dual-hosted git repository.
olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new f767d83fe Fix deprecated auto application of () to method invocations
f767d83fe is described below
commit f767d83fe8785775561c55872bdd4e0280c643ac
Author: olabusayoT <[email protected]>
AuthorDate: Thu Feb 6 11:57:46 2025 -0500
Fix deprecated auto application of () to method invocations
- add support for 2.13 scala options
- add explicit () to some method invocations
- fix some collections to explicitly used toSeq to return an immutable Seq
- replace string concat with + with interpolated strings or char prepend
where appropriate
- add coverage comments
DAFFODIL-2152
---
build.sbt | 19 ++++++++++++-------
.../schema/annotation/props/TestPropertyRuntime.scala | 2 +-
.../scala/org/apache/daffodil/lib/Implicits.scala | 4 +++-
.../scala/org/apache/daffodil/lib/TypedEquality.scala | 4 +++-
.../apache/daffodil/lib/calendar/DFDLCalendar.scala | 4 ++--
.../scala/org/apache/daffodil/lib/oolag/OOLAG.scala | 6 +++---
.../scala/org/apache/daffodil/lib/util/MStack.scala | 10 +++++-----
.../apache/daffodil/lib/util/TransitiveClosure.scala | 2 +-
.../daffodil/lib/validation/XercesValidator.scala | 2 +-
.../scala/org/apache/daffodil/lib/xml/XMLUtils.scala | 8 ++++----
.../lib/testEquality/TestEqualityOperators.scala | 2 +-
.../main/scala/org/apache/daffodil/io/IOMacros.scala | 6 +++---
.../org/apache/daffodil/lib/util/TimerMacros.scala | 16 ++++++++--------
.../apache/daffodil/propGen/PropertyGenerator.scala | 10 +++++-----
.../apache/daffodil/propGen/TunableGenerator.scala | 8 ++++----
.../org/apache/daffodil/propGen/WarnIDGenerator.scala | 2 +-
16 files changed, 57 insertions(+), 48 deletions(-)
diff --git a/build.sbt b/build.sbt
index 39999ae6a..8d0c9a6a0 100644
--- a/build.sbt
+++ b/build.sbt
@@ -277,18 +277,23 @@ def buildScalacOptions(scalaVersion: String) = {
"-unchecked",
"-Xfatal-warnings",
"-Xxml:-coalescing",
- "-Xfuture",
- "-Ywarn-infer-any",
- "-Ywarn-inaccessible",
- // "-Ywarn-nullary-unit", // we cannot use this. It interferes with the
Uniform Access Principle.
- // See
https://stackoverflow.com/questions/7600910/difference-between-function-with-parentheses-and-without.
- "-Ywarn-unused-import"
+ "-Ywarn-unused:imports"
)
val scalaVersionSpecificOptions = CrossVersion.partialVersion(scalaVersion)
match {
case Some((2, 12)) =>
Seq(
- "-Ywarn-unused:imports"
+ "-Xfuture",
+ "-Ywarn-infer-any",
+ "-Ywarn-inaccessible"
+ // "-Ywarn-nullary-unit", // we cannot use this. It interferes with
the Uniform Access Principle.
+ // See
https://stackoverflow.com/questions/7600910/difference-between-function-with-parentheses-and-without.
+ )
+ case Some((2, 13)) =>
+ Seq(
+ "-Xlint:inaccessible",
+ "-Xlint:infer-any",
+ "-Xlint:nullary-unit"
)
case _ => Seq.empty
}
diff --git
a/daffodil-core/src/test/scala/org/apache/daffodil/core/schema/annotation/props/TestPropertyRuntime.scala
b/daffodil-core/src/test/scala/org/apache/daffodil/core/schema/annotation/props/TestPropertyRuntime.scala
index 3bc7c1f12..62530e128 100644
---
a/daffodil-core/src/test/scala/org/apache/daffodil/core/schema/annotation/props/TestPropertyRuntime.scala
+++
b/daffodil-core/src/test/scala/org/apache/daffodil/core/schema/annotation/props/TestPropertyRuntime.scala
@@ -131,7 +131,7 @@ trait TheExamplePropMixin extends PropertyMixin { self:
HasMixin =>
var initWasCalled: Boolean = false
def init() = {
initWasCalled = true
- registerToStringFunction(() => theExamplePropToString)
+ registerToStringFunction(() => theExamplePropToString())
}
init() // call at object creation to initialize
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/Implicits.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/Implicits.scala
index 3a45ea083..3d07e4ee0 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/Implicits.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/Implicits.scala
@@ -28,7 +28,9 @@ import org.apache.daffodil.lib.xml.NS
object Implicits {
object ImplicitsSuppressUnusedImportWarning {
- def apply() = if (scala.math.random.isNaN()) Assert.impossible()
+ // $COVERAGE-OFF$
+ def apply() = if (scala.math.random().isNaN) Assert.impossible()
+ // $COVERAGE-ON$
}
/**
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/TypedEquality.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/TypedEquality.scala
index d48b86efb..bea388363 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/TypedEquality.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/TypedEquality.scala
@@ -36,7 +36,9 @@ import org.apache.daffodil.lib.exceptions.Assert
package object equality {
def EqualitySuppressUnusedImportWarning() = {
- if (scala.math.random.isNaN) Assert.impossible()
+ // $COVERAGE-OFF$
+ if (scala.math.random().isNaN) Assert.impossible()
+ // $COVERAGE-ON$
}
// Convertible types - strongly typed equality
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendar.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendar.scala
index c54044f96..ee63a5b3e 100644
---
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendar.scala
+++
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendar.scala
@@ -87,8 +87,8 @@ trait OrderedCalendar { self: DFDLCalendar =>
// Step 1 of the algorithm is to normalize the dates to Z time zone.
//
- val pPrime = p.getNormalizedCalendar
- val qPrime = q.getNormalizedCalendar
+ val pPrime = p.getNormalizedCalendar()
+ val qPrime = q.getNormalizedCalendar()
val res: DFDLCalendarOrder = {
if ((pHasTZ && qHasTZ) || (!pHasTZ && !qHasTZ)) {
orderCompareFields(pPrime, qPrime) }
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/oolag/OOLAG.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/oolag/OOLAG.scala
index 31856bff7..89dacb12d 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/oolag/OOLAG.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/oolag/OOLAG.scala
@@ -485,7 +485,7 @@ object OOLAG {
*/
def isError: Boolean = isErrorOnce
private lazy val isErrorOnce: Boolean = {
- oolagRoot.checkErrors
+ oolagRoot.checkErrors()
val errorCount = oolagRoot.errors.size
errorCount > 0
}
@@ -703,7 +703,7 @@ object OOLAG {
// this should make a substantial difference in schema compilation
time.
val res =
try {
- oolagBefore
+ oolagBefore()
val v = body // good place for a breakpoint
oolagAfterValue(v.asInstanceOf[AnyRef])
v
@@ -714,7 +714,7 @@ object OOLAG {
case e: Error => throw e
case th: Throwable => oolagCatch(th)
} finally {
- oolagFinalize
+ oolagFinalize()
}
res
}
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/MStack.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/MStack.scala
index b33d9fd2e..e8e68845e 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/MStack.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/MStack.scala
@@ -39,7 +39,7 @@ final class MStackOfBoolean private ()
object MStackOfBoolean {
def apply() = {
val stk = new MStackOfBoolean()
- stk.init
+ stk.init()
stk
}
}
@@ -49,7 +49,7 @@ final class MStackOfInt extends MStack[Int]((n: Int) => new
Array[Int](n), 0)
object MStackOfInt {
def apply() = {
val stk = new MStackOfInt()
- stk.init
+ stk.init()
stk
}
}
@@ -59,7 +59,7 @@ final class MStackOfLong extends MStack[Long]((n: Int) => new
Array[Long](n), 0L
object MStackOfLong {
def apply() = {
val stk = new MStackOfLong()
- stk.init
+ stk.init()
stk
}
}
@@ -149,7 +149,7 @@ final class MStackOf[T <: AnyRef] extends Serializable {
@inline final def reset(m: MStack.Mark) = delegate.reset(m)
@inline final def push(t: T) = delegate.push(t)
- @inline final def pop: T = delegate.pop.asInstanceOf[T]
+ @inline final def pop: T = delegate.pop().asInstanceOf[T]
@inline final def setTop(t: T) = delegate.setTop(t)
@inline final def top: T = delegate.top.asInstanceOf[T]
@inline final def bottom: T = delegate.bottom.asInstanceOf[T]
@@ -169,7 +169,7 @@ private[util] final class MStackOfAnyRef private ()
object MStackOfAnyRef {
def apply() = {
val stk = new MStackOfAnyRef()
- stk.init
+ stk.init()
stk
}
}
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/TransitiveClosure.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/TransitiveClosure.scala
index 7a9751659..d6cf26c82 100644
---
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/TransitiveClosure.scala
+++
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/TransitiveClosure.scala
@@ -37,7 +37,7 @@ abstract class TransitiveClosure[T] {
*/
private def tclose() = {
while (!items.isEmpty) {
- val hd = items.dequeue
+ val hd = items.dequeue()
if (!processed.contains(hd)) {
processed += hd
val newOnes = func(hd).filterNot(processed.contains(_)).distinct
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/validation/XercesValidator.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/validation/XercesValidator.scala
index b77511423..076a7d387 100644
---
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/validation/XercesValidator.scala
+++
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/validation/XercesValidator.scala
@@ -57,7 +57,7 @@ object XercesValidatorFactory {
if (config.hasPath(XercesValidator.name))
config.getStringList(XercesValidator.name).asScala
else Seq.empty
- XercesValidator.fromFiles(schemaFiles)
+ XercesValidator.fromFiles(schemaFiles.toSeq)
}
def makeConfig(uris: Seq[String]): Config = {
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala
index 7a0841d1b..2865455d5 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala
@@ -150,7 +150,7 @@ object XMLUtils {
pos += 1
}
- list
+ list.toSeq
}
private val remapXMLToPUA =
@@ -276,13 +276,13 @@ object XMLUtils {
}
} else {
// not an atom
- processText // if there is pending text output that first
+ processText() // if there is pending text output that first
ab += current // then the current non-atom node.
}
}
// we fell out of the loop. So
- processText // in case there is text left pending when we hit the end
- ab.result
+ processText() // in case there is text left pending when we hit the end
+ ab.result()
}
val XSD_NAMESPACE = NS(
diff --git
a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/testEquality/TestEqualityOperators.scala
b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/testEquality/TestEqualityOperators.scala
index 20fe46076..732640eb8 100644
---
a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/testEquality/TestEqualityOperators.scala
+++
b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/testEquality/TestEqualityOperators.scala
@@ -52,7 +52,7 @@ class TestEqualityOperators {
fail("equal")
}
- private val ylong = scala.math.random.toLong
+ private val ylong = scala.math.random().toLong
@Test
def testStronglyTypedEqualityInline(): Unit = {
diff --git
a/daffodil-macro-lib/src/main/scala/org/apache/daffodil/io/IOMacros.scala
b/daffodil-macro-lib/src/main/scala/org/apache/daffodil/io/IOMacros.scala
index 1b028c624..ca25b7c2b 100644
--- a/daffodil-macro-lib/src/main/scala/org/apache/daffodil/io/IOMacros.scala
+++ b/daffodil-macro-lib/src/main/scala/org/apache/daffodil/io/IOMacros.scala
@@ -34,9 +34,9 @@ object IOMacros {
import c.universe._
- val dStream = TermName(c.freshName)
- val newLengthLimit = TermName(c.freshName)
- val savedLengthLimit = TermName(c.freshName)
+ val dStream = TermName(c.freshName())
+ val newLengthLimit = TermName(c.freshName())
+ val savedLengthLimit = TermName(c.freshName())
// c.prefix is the expression this macro was expanded on. Not quite same
thing as 'this' because we have to be
// careful not to use it more than once or it will evaluate more than once.
val selfExp = c.prefix
diff --git
a/daffodil-macro-lib/src/main/scala/org/apache/daffodil/lib/util/TimerMacros.scala
b/daffodil-macro-lib/src/main/scala/org/apache/daffodil/lib/util/TimerMacros.scala
index 31918b698..92f0cfed0 100644
---
a/daffodil-macro-lib/src/main/scala/org/apache/daffodil/lib/util/TimerMacros.scala
+++
b/daffodil-macro-lib/src/main/scala/org/apache/daffodil/lib/util/TimerMacros.scala
@@ -24,14 +24,14 @@ object TimeTrackerMacros {
def trackMacro(c: Context)(name: c.Tree)(body: c.Tree) = {
import c.universe._
- val startTime = TermName(c.freshName)
- val endTime = TermName(c.freshName)
- val childrenTime = TermName(c.freshName)
- val timeTaken = TermName(c.freshName)
- val selfTime = TermName(c.freshName)
- val sectionTime = TermName(c.freshName)
- val result = TermName(c.freshName)
- val key = TermName(c.freshName)
+ val startTime = TermName(c.freshName())
+ val endTime = TermName(c.freshName())
+ val childrenTime = TermName(c.freshName())
+ val timeTaken = TermName(c.freshName())
+ val selfTime = TermName(c.freshName())
+ val sectionTime = TermName(c.freshName())
+ val result = TermName(c.freshName())
+ val key = TermName(c.freshName())
q"""
{
diff --git
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
index 695c9ab3d..7ba33b84e 100644
---
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
+++
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
@@ -90,7 +90,7 @@ class PropertyGenerator(arg: Node) {
}
}
})
- thunks
+ thunks.toSeq
}
/**
@@ -430,7 +430,7 @@ trait CurrencyMixin extends PropertyMixin {
}
final def currencyInit() = {
- registerToStringFunction(() => currencyToString)
+ registerToStringFunction(() => currencyToString())
}
currencyInit() // call at object creation to initialize
@@ -687,12 +687,12 @@ object Currency {
stripLast
}
- def initialUpperCase(s: String): String = s.head.toUpper + s.substring(1)
+ def initialUpperCase(s: String): String = s.head.toUpper +: s.substring(1)
def initialLowerCase(s: String): String = {
// special case for the way we lowercase the utf16Width property.
if (s == "UTF16Width") "utf16Width"
else
- s.head.toLower + s.substring(1)
+ s.head.toLower +: s.substring(1)
}
} // end trait
@@ -762,7 +762,7 @@ import org.apache.daffodil.lib.exceptions.ThrowsSDE
def getGeneratedFilePath(rootDir: String, pkg: String, filename: String):
String = {
val outDir = new java.io.File(rootDir + "/" + pkg.split('.').reduceLeft(_
+ "/" + _))
outDir.mkdirs()
- val outPath = outDir + "/" + filename
+ val outPath = s"$outDir/$filename"
outPath
}
diff --git
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/TunableGenerator.scala
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/TunableGenerator.scala
index bbdd232a9..62f75dc94 100644
---
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/TunableGenerator.scala
+++
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/TunableGenerator.scala
@@ -292,7 +292,7 @@ class EnumListTunable(
"Nil"
} else {
val defaultSeq =
- trimmedDefault.split("\\s+").map(d => s"${listType}.${d.head.toUpper +
d.tail}")
+ trimmedDefault.split("\\s+").map(d =>
s"${listType}.${d.head.toUpper}${d.tail}")
s"""Seq(${defaultSeq.mkString(", ")})"""
}
@@ -316,7 +316,7 @@ class TunableEnumDefinition(
simpleTypeNode: scala.xml.Node
) {
private val nodeName = (simpleTypeNode \@ "name").stripPrefix("Tunable")
- private val scalaType = nodeName.head.toUpper + nodeName.tail
+ private val scalaType = nodeName.head.toUpper +: nodeName.tail
/**
* Returns a list of all string values of enumerations. If a simpletype is a
@@ -352,12 +352,12 @@ class TunableEnumDefinition(
""".trim.stripMargin
private val scalaEnums = {
- val scalaEnumValues = allEnumerationValues.map { e => e.head.toUpper +
e.tail }
+ val scalaEnumValues = allEnumerationValues.map { e => e.head.toUpper +:
e.tail }
scalaEnumValues.map { e => s""" case object ${e} extends ${scalaType}""" }
}
private val values = {
- val scalaEnumValues = allEnumerationValues.map { e => e.head.toUpper +
e.tail }
+ val scalaEnumValues = allEnumerationValues.map { e => e.head.toUpper +:
e.tail }
scalaEnumValues.mkString(" override lazy val values = Array(", ", ", ")")
}
diff --git
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/WarnIDGenerator.scala
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/WarnIDGenerator.scala
index b93d8de86..55a1081ba 100644
---
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/WarnIDGenerator.scala
+++
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/WarnIDGenerator.scala
@@ -73,7 +73,7 @@ class WarnIDGenerator(schema: scala.xml.Node) {
val scalaNames = enumerationNodes.map { node =>
val enumName = node \@ "value"
- val scalaName = enumName.head.toUpper + enumName.tail
+ val scalaName = enumName.head.toUpper +: enumName.tail
scalaName
}