-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Angle brackets no longer cause malformed html reports
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 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
44 changes: 44 additions & 0 deletions
44
src/test/scala/com/sksamuel/scapegoat/io/HtmlReportWriterTest.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,44 @@ | ||
package com.sksamuel.scapegoat.io | ||
|
||
import com.sksamuel.scapegoat.{Levels, Warning} | ||
import org.scalatest.freespec.AnyFreeSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class HtmlReportWriterTest extends AnyFreeSpec with Matchers { | ||
|
||
"HtmlReportWriter" - { | ||
"should escape angle brackets" in { | ||
val warnings = Seq( | ||
Warning( | ||
"Pointless type bounds", | ||
13, | ||
Levels.Error, | ||
"/home/johnnei/git/scapegoat/src/main/scala/com/sksamuel/File.scala", | ||
"com.sksamuel.File.scala", | ||
None, | ||
explanation = "Finds type bounds of the form `A <: Any` or `A >: Nothing`.", | ||
inspection = "com.sksamuel.scapegoat.inspections.inference.PointlessTypeBounds" | ||
) | ||
) | ||
|
||
val escapedReport = Seq( | ||
<div class="warning"> | ||
<div class="source"> | ||
com.sksamuel.File.scala:13 | ||
</div> | ||
<div class="title"> | ||
<span class="label label-danger">Error</span> <span>Pointless type bounds</span> <span class="inspection"> | ||
com.sksamuel.scapegoat.inspections.inference.PointlessTypeBounds | ||
</span> | ||
</div> | ||
<div> | ||
<span>Finds type bounds of the form <code>A <: Any</code> or <code>A >: Nothing</code>.</span> | ||
</div> | ||
</div> | ||
) | ||
|
||
val report = HtmlReportWriter.warnings(warnings) | ||
report.toString() shouldEqual escapedReport.toString() | ||
} | ||
} | ||
} |