Skip to content

Commit 3a02728

Browse files
authored
Take care of deprecation warnings (#332)
1 parent b7e2232 commit 3a02728

File tree

12 files changed

+36
-33
lines changed

12 files changed

+36
-33
lines changed

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/IOUtils.scala

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ object IOUtils {
8080
acc += (line.split(" ").toList match {
8181
case List(idx, clazz) => (idx.toInt, clazz)
8282
case List(idx) => (idx.toInt, "")
83+
// This should never really happen but to avoid a match error we'll default to a 0
84+
// index here since we start with 1 anyways.
85+
case _ => (0, "")
8386
})
8487
}
8588
}

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/Serializer.scala

+17-17
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,32 @@ object Serializer {
7575
def coverageFile(dataDir: String): File = new File(dataDir, Constants.CoverageFileName)
7676

7777
def deserialize(file: File): Coverage = {
78-
deserialize(Source.fromFile(file)(Codec.UTF8).getLines)
78+
deserialize(Source.fromFile(file)(Codec.UTF8).getLines())
7979
}
8080

8181
def deserialize(lines: Iterator[String]): Coverage = {
8282
def toStatement(lines: Iterator[String]): Statement = {
83-
val id: Int = lines.next.toInt
84-
val sourcePath = lines.next
85-
val packageName = lines.next
86-
val className = lines.next
87-
val classType = lines.next
88-
val fullClassName = lines.next
89-
val method = lines.next
83+
val id: Int = lines.next().toInt
84+
val sourcePath = lines.next()
85+
val packageName = lines.next()
86+
val className = lines.next()
87+
val classType = lines.next()
88+
val fullClassName = lines.next()
89+
val method = lines.next()
9090
val loc = Location(packageName, className, fullClassName, ClassType.fromString(classType), method, sourcePath)
91-
val start: Int = lines.next.toInt
92-
val end: Int = lines.next.toInt
93-
val lineNo: Int = lines.next.toInt
94-
val symbolName: String = lines.next
95-
val treeName: String = lines.next
96-
val branch: Boolean = lines.next.toBoolean
97-
val count: Int = lines.next.toInt
98-
val ignored: Boolean = lines.next.toBoolean
91+
val start: Int = lines.next().toInt
92+
val end: Int = lines.next().toInt
93+
val lineNo: Int = lines.next().toInt
94+
val symbolName: String = lines.next()
95+
val treeName: String = lines.next()
96+
val branch: Boolean = lines.next().toBoolean
97+
val count: Int = lines.next().toInt
98+
val ignored: Boolean = lines.next().toBoolean
9999
val desc = lines.toList.mkString("\n")
100100
Statement(loc, id, start, end, lineNo, desc, symbolName, treeName, branch, count, ignored)
101101
}
102102

103-
val headerFirstLine = lines.next
103+
val headerFirstLine = lines.next()
104104
require(headerFirstLine == "# Coverage data, format version: 2.0", "Wrong file format")
105105

106106
val linesWithoutHeader = lines.dropWhile(_.startsWith("#"))

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/report/CoberturaXmlWriter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.xml.{Node, PrettyPrinter}
1010
/** @author Stephen Samuel */
1111
class CoberturaXmlWriter(sourceDirectories: Seq[File], outputDir: File) extends BaseReportWriter(sourceDirectories, outputDir) {
1212

13-
def this (baseDir: File, outputDir: File) {
13+
def this (baseDir: File, outputDir: File) = {
1414
this(Seq(baseDir), outputDir)
1515
}
1616

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/report/CodeGrid.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.io.Source
88
class CodeGrid(mFile: MeasuredFile, sourceEncoding: Option[String]) {
99

1010
// for backward compatibility only
11-
def this (mFile: MeasuredFile) {
11+
def this (mFile: MeasuredFile) = {
1212
this(mFile, None);
1313
}
1414

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/report/ScoverageHtmlWriter.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import scala.xml.Node
1111
class ScoverageHtmlWriter(sourceDirectories: Seq[File], outputDir: File, sourceEncoding: Option[String]) extends BaseReportWriter(sourceDirectories, outputDir) {
1212

1313
// to be used by gradle-scoverage plugin
14-
def this (sourceDirectories: Array[File], outputDir: File, sourceEncoding: Option[String]) {
14+
def this (sourceDirectories: Array[File], outputDir: File, sourceEncoding: Option[String]) = {
1515
this (sourceDirectories.toSeq, outputDir, sourceEncoding)
1616
}
1717

1818
// for backward compatibility only
19-
def this (sourceDirectories: Seq[File], outputDir: File) {
19+
def this (sourceDirectories: Seq[File], outputDir: File) = {
2020
this(sourceDirectories, outputDir, None);
2121
}
2222

2323
// for backward compatibility only
24-
def this (sourceDirectory: File, outputDir: File) {
24+
def this (sourceDirectory: File, outputDir: File) = {
2525
this(Seq(sourceDirectory), outputDir)
2626
}
2727

Diff for: scalac-scoverage-plugin/src/main/scala/scoverage/report/ScoverageXmlWriter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import scala.xml.{Node, PrettyPrinter}
99
/** @author Stephen Samuel */
1010
class ScoverageXmlWriter(sourceDirectories: Seq[File], outputDir: File, debug: Boolean) extends BaseReportWriter(sourceDirectories, outputDir) {
1111

12-
def this (sourceDir: File, outputDir: File, debug: Boolean) {
12+
def this (sourceDir: File, outputDir: File, debug: Boolean) = {
1313
this(Seq(sourceDir), outputDir, debug)
1414
}
1515

Diff for: scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object ScoverageCompiler {
2929

3030
val path = s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/test-generated-classes"
3131
new File(path).mkdirs()
32-
s.d.value = path
32+
s.outdir.value = path
3333
s
3434
}
3535

Diff for: scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageHtmlWriterTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ScoverageHtmlWriterTest extends AnyFunSuite {
5959
val htmls = List("overview.html", "coverage.sample.html")
6060

6161
for (html <- htmls) {
62-
val xml = XML.loadString(Source.fromFile(new File(outputDir, html)).getLines.mkString)
62+
val xml = XML.loadString(Source.fromFile(new File(outputDir, html)).getLines().mkString)
6363
val links = for (node <- xml \\ "a") yield {
6464
node.attribute("href") match {
6565
case Some(url) => url.toString
@@ -77,7 +77,7 @@ class ScoverageHtmlWriterTest extends AnyFunSuite {
7777
coverage.add(statementForClassContainingHtml)
7878
val outputDir = writeCoverageToTemporaryDir(coverage)
7979

80-
val contentsOfFileWithEmbeddedHtml = Source.fromFile(new File(outputDir, "ClassContainingHtml.scala.html")).getLines.mkString
80+
val contentsOfFileWithEmbeddedHtml = Source.fromFile(new File(outputDir, "ClassContainingHtml.scala.html")).getLines().mkString
8181
assert( !contentsOfFileWithEmbeddedHtml.contains("<div>HTML content</div>") )
8282
assert( contentsOfFileWithEmbeddedHtml.contains("&lt;div&gt;HTML content&lt;/div&gt;") )
8383
}

Diff for: scalac-scoverage-runtime/js/src/main/scala/scalajssupport/FileWriter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class FileWriter(file: File, append: Boolean) {
99
def this(file: String, append: Boolean) = this(new File(file), append)
1010

1111
def append(csq: CharSequence) = {
12-
File.write(file.getPath, csq.toString)
12+
File.write(file.getPath(), csq.toString)
1313
this
1414
}
1515

Diff for: scalac-scoverage-runtime/js/src/main/scala/scalajssupport/Source.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Source {
1010
def fromFile(file: File) = {
1111
new OrigSource {
1212

13-
val iter = file.readFile.toCharArray.iterator
13+
val iter = file.readFile().toCharArray.iterator
1414
}
1515
}
16-
}
16+
}

Diff for: scalac-scoverage-runtime/shared/src/main/scala/scoverage/Invoker.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ object Invoker {
6868
.find(name => name.endsWith("suite") || name.endsWith("spec") || name.endsWith("test"))
6969
.getOrElse("")
7070

71-
def measurementFile(dataDir: File): File = measurementFile(dataDir.getAbsolutePath)
71+
def measurementFile(dataDir: File): File = measurementFile(dataDir.getAbsolutePath())
7272
def measurementFile(dataDir: String): File = new File(dataDir, MeasurementsPrefix + runtimeUUID + "." + Thread.currentThread.getId)
7373

7474
def findMeasurementFiles(dataDir: String): Array[File] = findMeasurementFiles(new File(dataDir))
7575
def findMeasurementFiles(dataDir: File): Array[File] = dataDir.listFiles(new FileFilter {
76-
override def accept(pathname: File): Boolean = pathname.getName.startsWith(MeasurementsPrefix)
76+
override def accept(pathname: File): Boolean = pathname.getName().startsWith(MeasurementsPrefix)
7777
})
7878

7979
// loads all the invoked statement ids from the given files

Diff for: scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class InvokerMultiModuleTest extends AnyFunSuite with BeforeAndAfter {
3939

4040
after {
4141
deleteMeasurementFiles()
42-
measurementDir.foreach(_.delete)
42+
measurementDir.foreach(_.delete())
4343
}
4444

4545
private def deleteMeasurementFiles(): Unit = {
4646
measurementDir.foreach((md) => {
47-
if (md.isDirectory)
47+
if (md.isDirectory())
4848
md.listFiles().foreach(_.delete())
4949
})
5050
}

0 commit comments

Comments
 (0)