Skip to content

Commit 1ae52e0

Browse files
committed
Added to junit failureXml, print content according to 'https://www.ibm.com/docs/en/developer-for-zos/14.1.0?topic=formats-junit-xml-format'
1 parent 947834f commit 1ae52e0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/printers/junitxml.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package printers
33
import (
44
"context"
55
"encoding/xml"
6+
"fmt"
67
"strings"
78

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

3233
type failureXML struct {
3334
Message string `xml:"message,attr"`
35+
Type string `xml:"type,attr"`
3436
Content string `xml:",cdata"`
3537
}
3638

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

0 commit comments

Comments
 (0)