-
Notifications
You must be signed in to change notification settings - Fork 126
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
Allow to handle "no source root found" in a custom way #525
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,22 @@ import scoverage.domain.MeasuredPackage | |
class CoberturaXmlWriter( | ||
sourceDirectories: Seq[File], | ||
outputDir: File, | ||
sourceEncoding: Option[String] | ||
) extends BaseReportWriter(sourceDirectories, outputDir, sourceEncoding) { | ||
sourceEncoding: Option[String], | ||
recoverNoSourceRoot: BaseReportWriter.PathRecoverer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think we'll need to handle this a bit differently. These would be breaking changes for all the reporters, meaning another major bump, and I don't think we want to do another major atm. Can we potentially switch these up to either have a default implementation for this or another way that won't break compat for existing tools that are using this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand. |
||
) extends BaseReportWriter( | ||
sourceDirectories, | ||
outputDir, | ||
sourceEncoding, | ||
recoverNoSourceRoot | ||
) { | ||
|
||
def this(baseDir: File, outputDir: File, sourceEncoding: Option[String]) = { | ||
this(Seq(baseDir), outputDir, sourceEncoding) | ||
def this( | ||
baseDir: File, | ||
outputDir: File, | ||
sourceEncoding: Option[String], | ||
recoverNoSourceRoot: BaseReportWriter.PathRecoverer | ||
) = { | ||
this(Seq(baseDir), outputDir, sourceEncoding, recoverNoSourceRoot) | ||
} | ||
|
||
def write(coverage: Coverage): Unit = { | ||
|
@@ -49,24 +60,26 @@ class CoberturaXmlWriter( | |
</method> | ||
} | ||
|
||
def klass(klass: MeasuredClass): Node = { | ||
<class name={klass.fullClassName} | ||
filename={relativeSource(klass.source)} | ||
line-rate={DoubleFormat.twoFractionDigits(klass.statementCoverage)} | ||
branch-rate={DoubleFormat.twoFractionDigits(klass.branchCoverage)} | ||
complexity="0"> | ||
<methods> | ||
{klass.methods.map(method)} | ||
</methods> | ||
<lines> | ||
{ | ||
klass.statements.map(stmt => <line | ||
number={stmt.line.toString} | ||
hits={stmt.count.toString} | ||
branch={stmt.branch.toString}/>) | ||
} | ||
</lines> | ||
</class> | ||
def klass(klass: MeasuredClass): Option[Node] = { | ||
relativeSource(klass.source).map(sourcePath => { | ||
<class name={klass.fullClassName} | ||
filename={sourcePath} | ||
line-rate={DoubleFormat.twoFractionDigits(klass.statementCoverage)} | ||
branch-rate={DoubleFormat.twoFractionDigits(klass.branchCoverage)} | ||
complexity="0"> | ||
<methods> | ||
{klass.methods.map(method)} | ||
</methods> | ||
<lines> | ||
{ | ||
klass.statements.map(stmt => <line | ||
number={stmt.line.toString} | ||
hits={stmt.count.toString} | ||
branch={stmt.branch.toString}/>) | ||
} | ||
</lines> | ||
</class> | ||
}) | ||
} | ||
|
||
def pack(pack: MeasuredPackage): Node = { | ||
|
@@ -75,7 +88,7 @@ class CoberturaXmlWriter( | |
branch-rate={DoubleFormat.twoFractionDigits(pack.branchCoverage)} | ||
complexity="0"> | ||
<classes> | ||
{pack.classes.map(klass)} | ||
{pack.classes.flatMap(klass)} | ||
</classes> | ||
</package> | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, maybe personal preference so take it or leave it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I hesitated 😄