-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added option to display branch coverage in new Scala report, converte…
…d Java to Scala, fixed ScalaDoc warning, misc small other cleanup
- Loading branch information
Joachim Hofer
committed
Oct 19, 2013
1 parent
f914fa3
commit 52d0940
Showing
8 changed files
with
66 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
src/main/scala/de/johoop/jacoco4sbt/ScalaHtmlFormatter.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
src/main/scala/de/johoop/jacoco4sbt/ScalaHtmlFormatter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.johoop.jacoco4sbt | ||
|
||
import org.jacoco.core.analysis.ICoverageNode | ||
import org.jacoco.report.html.HTMLFormatter | ||
import org.jacoco.report.internal.html.resources.Styles | ||
import org.jacoco.report.internal.html.table._ | ||
import scala.Some | ||
|
||
/** | ||
* Omits displaying instruction and branch coverage in the coverage tables, | ||
* as Scala generates null checks which make these too noisy. | ||
* | ||
* TODO: Find a way to remove them from the annotated source code reports, too. | ||
*/ | ||
class ScalaHtmlFormatter(withBranchCoverage: Boolean) extends HTMLFormatter { | ||
private var table: Option[Table] = None | ||
|
||
setLanguageNames(new ScalaLanguageNames) | ||
|
||
override def getTable: Table = { | ||
table getOrElse { | ||
val newTable = createTable | ||
table = Some(newTable) | ||
newTable | ||
} | ||
} | ||
|
||
private def createTable: Table = { | ||
val t: Table = new Table | ||
t.add("Element", null, new LabelColumn, false) | ||
t.add("Missed Lines", Styles.BAR, new BarColumn(ICoverageNode.CounterEntity.LINE, getLocale), true) | ||
t.add("Total Lines", Styles.CTR1, CounterColumn.newTotal(ICoverageNode.CounterEntity.LINE, getLocale), false) | ||
if (withBranchCoverage) { | ||
t.add("Missed Branches", Styles.BAR, new BarColumn(ICoverageNode.CounterEntity.BRANCH, getLocale), false) | ||
t.add("Cov.", Styles.CTR2, new PercentageColumn(ICoverageNode.CounterEntity.BRANCH, getLocale), false) | ||
} | ||
addMissedTotalColumns(t, "Methods", ICoverageNode.CounterEntity.METHOD) | ||
addMissedTotalColumns(t, "Classes", ICoverageNode.CounterEntity.CLASS) | ||
|
||
t | ||
} | ||
|
||
private def addMissedTotalColumns(table: Table, label: String, entity: ICoverageNode.CounterEntity) { | ||
table.add("Missed", Styles.CTR1, CounterColumn.newMissed(entity, getLocale), false) | ||
table.add(label, Styles.CTR2, CounterColumn.newTotal(entity, getLocale), false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters