Skip to content

Commit

Permalink
Added to junit failureXml, print content according to 'https://www.ib…
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Jan 5, 2022
1 parent 947834f commit 1ae52e0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/printers/junitxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package printers
import (
"context"
"encoding/xml"
"fmt"
"strings"

"github.com/golangci/golangci-lint/pkg/logutils"
Expand Down Expand Up @@ -31,6 +32,7 @@ type testCaseXML struct {

type failureXML struct {
Message string `xml:"message,attr"`
Type string `xml:"type,attr"`
Content string `xml:",cdata"`
}

Expand All @@ -56,8 +58,10 @@ func (JunitXML) Print(ctx context.Context, issues []result.Issue) error {
Name: i.FromLinter,
ClassName: i.Pos.String(),
Failure: failureXML{
Type: i.Severity,
Message: i.Pos.String() + ": " + i.Text,
Content: i.Pos.String() + ": " + i.Text + "\n" + strings.Join(i.SourceLines, "\n"),
Content: fmt.Sprintf("%s: %s\nCategory: %s\nFile: %s\nLine: %d\nDetails: %s",
i.Severity, i.Text, i.FromLinter, i.Pos.Filename, i.Pos.Line, strings.Join(i.SourceLines, "\n")),
},
}

Expand Down

0 comments on commit 1ae52e0

Please sign in to comment.