From 027dc2b8a7ee4169b6bcd176a0d3a8a7d6f809c9 Mon Sep 17 00:00:00 2001 From: NeverOddOrEven <2084348+NeverOddOrEven@users.noreply.github.com> Date: Wed, 3 Oct 2018 13:17:25 -0500 Subject: [PATCH] This fixes the html template when using '-fmt=html' - resolves HTML escaping issues within the template - resolves reference issues to reportInfo struct i.e. issues -> Issues, metrics -> Stats --- output/template.go | 59 +++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/output/template.go b/output/template.go index f7dd236..c69f586 100644 --- a/output/template.go +++ b/output/template.go @@ -62,7 +62,7 @@ const html = ` level = "is-warning"; } return ( -
+
{ this.props.label }: { this.props.level }
); @@ -100,8 +100,8 @@ const html = ` render: function() { return (

- Scanned { this.props.data.metrics.files.toLocaleString() } files - with { this.props.data.metrics.lines.toLocaleString() } lines of code. + Scanned { this.props.data.Stats.files.toLocaleString() } files + with { this.props.data.Stats.lines.toLocaleString() } lines of code.

); } @@ -109,7 +109,7 @@ const html = ` var Issues = React.createClass({ render: function() { - if (this.props.data.metrics.files === 0) { + if (this.props.data.Stats.files === 0) { return (
No source files found. Do you even Go? @@ -117,7 +117,7 @@ const html = ` ); } - if (this.props.data.issues.length === 0) { + if (this.props.data.Issues.length === 0) { return (
@@ -128,7 +128,7 @@ const html = ` ); } - var issues = this.props.data.issues + var issues = this.props.data.Issues .filter(function(issue) { return this.props.severity.includes(issue.severity); }.bind(this)) @@ -151,7 +151,7 @@ const html = `
No issues matched given filters - (of total { this.props.data.issues.length } issues). + (of total { this.props.data.Issues.length } issues).
@@ -182,31 +182,32 @@ const html = ` var highDisabled = !this.props.available.includes("HIGH"); var mediumDisabled = !this.props.available.includes("MEDIUM"); var lowDisabled = !this.props.available.includes("LOW"); - + var on = "", off = "disabled"; + var HIGH = "HIGH", MEDIUM = "MEDIUM", LOW = "LOW"; return ( - @@ -231,13 +232,13 @@ const html = ` render: function() { var issueTypes = this.props.allIssueTypes .map(function(it) { + var matches = this.props.issueType == it return ( - ); }.bind(this)); - return (