fix sonarIssues struct

This commit is contained in:
kencrawford 2019-03-11 17:32:32 -04:00 committed by Grant Murphy
parent 8eab50eb17
commit 1b28d323d8
2 changed files with 7 additions and 3 deletions

View file

@ -102,7 +102,7 @@ func CreateReport(w io.Writer, format, rootPath string, issues []*gosec.Issue, m
}
func reportSonarqube(rootPath string, w io.Writer, data *reportInfo) error {
var sonarIssues []sonarIssue
var si sonarIssues
for _, issue := range data.Issues {
lines := strings.Split(issue.Line, "-")
@ -123,9 +123,9 @@ func reportSonarqube(rootPath string, w io.Writer, data *reportInfo) error {
Severity: getSonarSeverity(issue.Severity.String()),
EffortMinutes: 5,
}
sonarIssues = append(sonarIssues, s)
si.SonarIssues = append(si.SonarIssues, s)
}
raw, err := json.MarshalIndent(sonarIssues, "", "\t")
raw, err := json.MarshalIndent(si, "", "\t")
if err != nil {
panic(err)
}

View file

@ -22,6 +22,10 @@ type sonarIssue struct {
SecondaryLocations []location `json:"secondaryLocations,omitempty"`
}
type sonarIssues struct {
SonarIssues []sonarIssue `json:"issues"`
}
func getSonarSeverity(s string) string {
switch s {
case "LOW":