Skip to content

Commit 0259a56

Browse files
committed
dev: cleanup printers
1 parent 980a911 commit 0259a56

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

pkg/printers/codeclimate.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,35 @@ func NewCodeClimate(log logutils.Log, w io.Writer) *CodeClimate {
3131
}
3232

3333
func (p *CodeClimate) Print(issues []result.Issue) error {
34-
codeClimateIssues := make([]CodeClimateIssue, 0, len(issues))
34+
ccIssues := make([]codeClimateIssue, 0, len(issues))
3535

3636
for i := range issues {
3737
issue := issues[i]
3838

39-
codeClimateIssue := CodeClimateIssue{}
40-
codeClimateIssue.Description = issue.Description()
41-
codeClimateIssue.CheckName = issue.FromLinter
42-
codeClimateIssue.Location.Path = issue.Pos.Filename
43-
codeClimateIssue.Location.Lines.Begin = issue.Pos.Line
44-
codeClimateIssue.Fingerprint = issue.Fingerprint()
45-
codeClimateIssue.Severity = p.sanitizer.Sanitize(issue.Severity)
39+
ccIssue := codeClimateIssue{}
40+
ccIssue.Description = issue.Description()
41+
ccIssue.CheckName = issue.FromLinter
42+
ccIssue.Location.Path = issue.Pos.Filename
43+
ccIssue.Location.Lines.Begin = issue.Pos.Line
44+
ccIssue.Fingerprint = issue.Fingerprint()
45+
ccIssue.Severity = p.sanitizer.Sanitize(issue.Severity)
4646

47-
codeClimateIssues = append(codeClimateIssues, codeClimateIssue)
47+
ccIssues = append(ccIssues, ccIssue)
4848
}
4949

5050
err := p.sanitizer.Err()
5151
if err != nil {
5252
p.log.Infof("%v", err)
5353
}
5454

55-
return json.NewEncoder(p.w).Encode(codeClimateIssues)
55+
return json.NewEncoder(p.w).Encode(ccIssues)
5656
}
5757

58-
// CodeClimateIssue is a subset of the Code Climate spec.
58+
// codeClimateIssue is a subset of the Code Climate spec.
5959
// https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types
6060
// It is just enough to support GitLab CI Code Quality.
6161
// https://docs.gitlab.com/ee/ci/testing/code_quality.html#code-quality-report-format
62-
type CodeClimateIssue struct {
62+
type codeClimateIssue struct {
6363
Description string `json:"description"`
6464
CheckName string `json:"check_name"`
6565
Severity string `json:"severity,omitempty"`

pkg/printers/junitxml.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ import (
1212
"github.com/golangci/golangci-lint/pkg/result"
1313
)
1414

15-
// JunitXML prints issues in the Junit XML format.
15+
// JUnitXML prints issues in the Junit XML format.
1616
// There is no official specification for the JUnit XML file format,
1717
// and various tools generate and support different flavors of this format.
1818
// https://github.com/testmoapp/junitxml
19-
type JunitXML struct {
19+
type JUnitXML struct {
2020
extended bool
2121
w io.Writer
2222
}
2323

24-
func NewJunitXML(w io.Writer, extended bool) *JunitXML {
25-
return &JunitXML{
24+
func NewJUnitXML(w io.Writer, extended bool) *JUnitXML {
25+
return &JUnitXML{
2626
extended: extended,
2727
w: w,
2828
}
2929
}
3030

31-
func (p JunitXML) Print(issues []result.Issue) error {
31+
func (p JUnitXML) Print(issues []result.Issue) error {
3232
suites := make(map[string]testSuiteXML) // use a map to group by file
3333

3434
for ind := range issues {

pkg/printers/junitxml_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Details: func foo() {
105105
t.Parallel()
106106

107107
buf := new(bytes.Buffer)
108-
printer := NewJunitXML(buf, test.extended)
108+
printer := NewJUnitXML(buf, test.extended)
109109

110110
err := printer.Print(issues)
111111
require.NoError(t, err)

pkg/printers/printer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error
128128
case config.OutFormatHTML:
129129
p = NewHTML(w)
130130
case config.OutFormatJunitXML, config.OutFormatJunitXMLExtended:
131-
p = NewJunitXML(w, format == config.OutFormatJunitXMLExtended)
131+
p = NewJUnitXML(w, format == config.OutFormatJunitXMLExtended)
132132
case config.OutFormatGithubActions:
133133
p = NewGitHubAction(w)
134134
case config.OutFormatTeamCity:
@@ -168,11 +168,11 @@ func (s *severitySanitizer) Err() error {
168168
return nil
169169
}
170170

171-
var foo []string
171+
var names []string
172172
for k := range s.unsupportedSeverities {
173-
foo = append(foo, "'"+k+"'")
173+
names = append(names, "'"+k+"'")
174174
}
175175

176-
return fmt.Errorf("some severities (%v) are not inside supported values (%v), fallback to '%s'",
177-
strings.Join(foo, ", "), strings.Join(s.allowedSeverities, ", "), s.defaultSeverity)
176+
return fmt.Errorf("severities (%v) are not inside supported values (%v), fallback to '%s'",
177+
strings.Join(names, ", "), strings.Join(s.allowedSeverities, ", "), s.defaultSeverity)
178178
}

pkg/printers/tab.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/golangci/golangci-lint/pkg/result"
1212
)
1313

14-
// Tab prints issues using tabulation as field separator.
14+
// Tab prints issues using tabulation as a field separator.
1515
type Tab struct {
1616
printLinterName bool
1717
useColors bool

0 commit comments

Comments
 (0)