com.google.code.scoverage.report.ScoverageHtmlWriterPatched.scala Maven / Gradle / Ivy
package com.google.code.scoverage.report
import scoverage._
import scoverage.report.ScoverageHtmlWriter
import scala.xml.Node
import scoverage.MeasuredFile
import java.io.File
import org.apache.commons.io.FileUtils
/** @author Stephen Samuel, Grzegorz Slowikowski */
class ScoverageHtmlWriterPatched(sourceDirectory: File, outputDir: File) extends ScoverageHtmlWriter(sourceDirectory, outputDir) {
override def write(pack: MeasuredPackage) {
val file = new File(outputDir.getAbsolutePath + "/" + pack.name.replace("", "(empty)").replace('.', '/') + "/package.html")
file.getParentFile.mkdirs()
FileUtils.write(file, packageClasses(pack).toString())
pack.files.foreach(write(_, file.getParentFile))
}
override def _class(klass: MeasuredClass, addPath: Boolean): Node = {
val filename: String = {
val fileRelativeToSource = new File(
klass.source.replace(
sourceDirectory.getAbsolutePath + File.separator,
"") + ".html")
val path = fileRelativeToSource.getParent
val value = fileRelativeToSource.getName
if (addPath && path.eq(null)) {
"(empty)/" + value
} else if (addPath && path.ne("")) {
// (Normalise the pathSeparator to "/" in case we are running on Windows)
fileRelativeToSource.toString.replace(File.separator, "/")
} else {
value
}
}
val statement0f = Math.round(klass.statementCoveragePercent).toInt.toString
val branch0f = Math.round(klass.branchCoveragePercent).toInt.toString
val simpleClassName = klass.name.split('.').last
{simpleClassName}
{klass.statements.headOption.map(_.source.split(File.separatorChar).last).getOrElse("")}
{klass.loc.toString}
{klass.methodCount.toString}
{klass.statementCount.toString}
{klass.invokedStatementCount.toString}
{klass.statementCoverageFormatted}
%
{klass.branchCount.toString}
{klass.invokedBranchesCount.toString}
{klass.branchCoverageFormatted}
%
}
override def packages(coverage: Coverage): Node = {
Scoverage Code Coverage
All packages
{coverage.statementCoverageFormatted}
%
{coverage.packages.map(arg =>
", "(empty)").replace('.', '/') + "/package.html"} target="mainFrame">
{arg.name}
{arg.statementCoverageFormatted}
%
)}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy