Skip to content

Take care of deprecation warnings #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ object IOUtils {
acc += (line.split(" ").toList match {
case List(idx, clazz) => (idx.toInt, clazz)
case List(idx) => (idx.toInt, "")
// This should never really happen but to avoid a match error we'll default to a 0
// index here since we start with 1 anyways.
case _ => (0, "")
})
}
}
Expand Down
34 changes: 17 additions & 17 deletions scalac-scoverage-plugin/src/main/scala/scoverage/Serializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,32 @@ object Serializer {
def coverageFile(dataDir: String): File = new File(dataDir, Constants.CoverageFileName)

def deserialize(file: File): Coverage = {
deserialize(Source.fromFile(file)(Codec.UTF8).getLines)
deserialize(Source.fromFile(file)(Codec.UTF8).getLines())
}

def deserialize(lines: Iterator[String]): Coverage = {
def toStatement(lines: Iterator[String]): Statement = {
val id: Int = lines.next.toInt
val sourcePath = lines.next
val packageName = lines.next
val className = lines.next
val classType = lines.next
val fullClassName = lines.next
val method = lines.next
val id: Int = lines.next().toInt
val sourcePath = lines.next()
val packageName = lines.next()
val className = lines.next()
val classType = lines.next()
val fullClassName = lines.next()
val method = lines.next()
val loc = Location(packageName, className, fullClassName, ClassType.fromString(classType), method, sourcePath)
val start: Int = lines.next.toInt
val end: Int = lines.next.toInt
val lineNo: Int = lines.next.toInt
val symbolName: String = lines.next
val treeName: String = lines.next
val branch: Boolean = lines.next.toBoolean
val count: Int = lines.next.toInt
val ignored: Boolean = lines.next.toBoolean
val start: Int = lines.next().toInt
val end: Int = lines.next().toInt
val lineNo: Int = lines.next().toInt
val symbolName: String = lines.next()
val treeName: String = lines.next()
val branch: Boolean = lines.next().toBoolean
val count: Int = lines.next().toInt
val ignored: Boolean = lines.next().toBoolean
val desc = lines.toList.mkString("\n")
Statement(loc, id, start, end, lineNo, desc, symbolName, treeName, branch, count, ignored)
}

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

val linesWithoutHeader = lines.dropWhile(_.startsWith("#"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.xml.{Node, PrettyPrinter}
/** @author Stephen Samuel */
class CoberturaXmlWriter(sourceDirectories: Seq[File], outputDir: File) extends BaseReportWriter(sourceDirectories, outputDir) {

def this (baseDir: File, outputDir: File) {
def this (baseDir: File, outputDir: File) = {
this(Seq(baseDir), outputDir)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.io.Source
class CodeGrid(mFile: MeasuredFile, sourceEncoding: Option[String]) {

// for backward compatibility only
def this (mFile: MeasuredFile) {
def this (mFile: MeasuredFile) = {
this(mFile, None);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import scala.xml.Node
class ScoverageHtmlWriter(sourceDirectories: Seq[File], outputDir: File, sourceEncoding: Option[String]) extends BaseReportWriter(sourceDirectories, outputDir) {

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

// for backward compatibility only
def this (sourceDirectories: Seq[File], outputDir: File) {
def this (sourceDirectories: Seq[File], outputDir: File) = {
this(sourceDirectories, outputDir, None);
}

// for backward compatibility only
def this (sourceDirectory: File, outputDir: File) {
def this (sourceDirectory: File, outputDir: File) = {
this(Seq(sourceDirectory), outputDir)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.xml.{Node, PrettyPrinter}
/** @author Stephen Samuel */
class ScoverageXmlWriter(sourceDirectories: Seq[File], outputDir: File, debug: Boolean) extends BaseReportWriter(sourceDirectories, outputDir) {

def this (sourceDir: File, outputDir: File, debug: Boolean) {
def this (sourceDir: File, outputDir: File, debug: Boolean) = {
this(Seq(sourceDir), outputDir, debug)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ScoverageCompiler {

val path = s"./scalac-scoverage-plugin/target/scala-$ScalaVersion/test-generated-classes"
new File(path).mkdirs()
s.d.value = path
s.outdir.value = path
s
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ScoverageHtmlWriterTest extends AnyFunSuite {
val htmls = List("overview.html", "coverage.sample.html")

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

val contentsOfFileWithEmbeddedHtml = Source.fromFile(new File(outputDir, "ClassContainingHtml.scala.html")).getLines.mkString
val contentsOfFileWithEmbeddedHtml = Source.fromFile(new File(outputDir, "ClassContainingHtml.scala.html")).getLines().mkString
assert( !contentsOfFileWithEmbeddedHtml.contains("<div>HTML content</div>") )
assert( contentsOfFileWithEmbeddedHtml.contains("&lt;div&gt;HTML content&lt;/div&gt;") )
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FileWriter(file: File, append: Boolean) {
def this(file: String, append: Boolean) = this(new File(file), append)

def append(csq: CharSequence) = {
File.write(file.getPath, csq.toString)
File.write(file.getPath(), csq.toString)
this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Source {
def fromFile(file: File) = {
new OrigSource {

val iter = file.readFile.toCharArray.iterator
val iter = file.readFile().toCharArray.iterator
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ object Invoker {
.find(name => name.endsWith("suite") || name.endsWith("spec") || name.endsWith("test"))
.getOrElse("")

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

def findMeasurementFiles(dataDir: String): Array[File] = findMeasurementFiles(new File(dataDir))
def findMeasurementFiles(dataDir: File): Array[File] = dataDir.listFiles(new FileFilter {
override def accept(pathname: File): Boolean = pathname.getName.startsWith(MeasurementsPrefix)
override def accept(pathname: File): Boolean = pathname.getName().startsWith(MeasurementsPrefix)
})

// loads all the invoked statement ids from the given files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class InvokerMultiModuleTest extends AnyFunSuite with BeforeAndAfter {

after {
deleteMeasurementFiles()
measurementDir.foreach(_.delete)
measurementDir.foreach(_.delete())
}

private def deleteMeasurementFiles(): Unit = {
measurementDir.foreach((md) => {
if (md.isDirectory)
if (md.isDirectory())
md.listFiles().foreach(_.delete())
})
}
Expand Down