Skip to content

Commit e27a44f

Browse files
committed
dev: remove unused ctx parameter from Printer
Enable revive rule for detecting this.
1 parent 5d34936 commit e27a44f

23 files changed

+26
-45
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ linters-settings:
6767
rules:
6868
- name: unexported-return
6969
disabled: true
70+
- name: unused-parameter
7071

7172
linters:
7273
disable-all: true

pkg/commands/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
411411
out = append(out, "")
412412
}
413413

414-
err := e.printReports(ctx, issues, out[1], out[0])
414+
err := e.printReports(issues, out[1], out[0])
415415
if err != nil {
416416
return err
417417
}
@@ -424,7 +424,7 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
424424
return nil
425425
}
426426

427-
func (e *Executor) printReports(ctx context.Context, issues []result.Issue, path, format string) error {
427+
func (e *Executor) printReports(issues []result.Issue, path, format string) error {
428428
w, shouldClose, err := e.createWriter(path)
429429
if err != nil {
430430
return fmt.Errorf("can't create output for %s: %w", path, err)
@@ -438,7 +438,7 @@ func (e *Executor) printReports(ctx context.Context, issues []result.Issue, path
438438
return err
439439
}
440440

441-
if err = p.Print(ctx, issues); err != nil {
441+
if err = p.Print(issues); err != nil {
442442
if file, ok := w.(io.Closer); shouldClose && ok {
443443
_ = file.Close()
444444
}

pkg/golinters/gocritic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ func (l *tLog) Infof(format string, args ...any) {
5656
log.Printf(format, args...)
5757
}
5858

59-
func (l *tLog) Child(name string) logutils.Log { return nil }
59+
func (l *tLog) Child(_ string) logutils.Log { return nil }
6060

61-
func (l *tLog) SetLevel(level logutils.LogLevel) {}
61+
func (l *tLog) SetLevel(_ logutils.LogLevel) {}

pkg/logutils/logutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var enabledDebugs = getEnabledDebugs()
7979

8080
type DebugFunc func(format string, args ...any)
8181

82-
func nopDebugf(format string, args ...any) {}
82+
func nopDebugf(_ string, _ ...any) {}
8383

8484
func Debug(tag string) DebugFunc {
8585
if !enabledDebugs[tag] {

pkg/printers/checkstyle.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"encoding/xml"
65
"fmt"
76
"io"
@@ -41,7 +40,7 @@ func NewCheckstyle(w io.Writer) *Checkstyle {
4140
return &Checkstyle{w: w}
4241
}
4342

44-
func (p Checkstyle) Print(ctx context.Context, issues []result.Issue) error {
43+
func (p Checkstyle) Print(issues []result.Issue) error {
4544
out := checkstyleOutput{
4645
Version: "5.0",
4746
}

pkg/printers/checkstyle_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"strings"
87
"testing"
@@ -47,7 +46,7 @@ func TestCheckstyle_Print(t *testing.T) {
4746
buf := new(bytes.Buffer)
4847
printer := NewCheckstyle(buf)
4948

50-
err := printer.Print(context.Background(), issues)
49+
err := printer.Print(issues)
5150
require.NoError(t, err)
5251

5352
//nolint:lll

pkg/printers/codeclimate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"encoding/json"
65
"fmt"
76
"io"
@@ -35,7 +34,7 @@ func NewCodeClimate(w io.Writer) *CodeClimate {
3534
return &CodeClimate{w: w}
3635
}
3736

38-
func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error {
37+
func (p CodeClimate) Print(issues []result.Issue) error {
3938
codeClimateIssues := make([]CodeClimateIssue, 0, len(issues))
4039
for i := range issues {
4140
issue := &issues[i]

pkg/printers/codeclimate_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -61,7 +60,7 @@ func TestCodeClimate_Print(t *testing.T) {
6160
buf := new(bytes.Buffer)
6261
printer := NewCodeClimate(buf)
6362

64-
err := printer.Print(context.Background(), issues)
63+
err := printer.Print(issues)
6564
require.NoError(t, err)
6665

6766
//nolint:lll

pkg/printers/github.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"fmt"
65
"io"
76

@@ -36,7 +35,7 @@ func formatIssueAsGithub(issue *result.Issue) string {
3635
return ret
3736
}
3837

39-
func (p *github) Print(_ context.Context, issues []result.Issue) error {
38+
func (p *github) Print(issues []result.Issue) error {
4039
for ind := range issues {
4140
_, err := fmt.Fprintln(p.w, formatIssueAsGithub(&issues[ind]))
4241
if err != nil {

pkg/printers/github_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package printers
33

44
import (
55
"bytes"
6-
"context"
76
"go/token"
87
"testing"
98

@@ -47,7 +46,7 @@ func TestGithub_Print(t *testing.T) {
4746
buf := new(bytes.Buffer)
4847
printer := NewGithub(buf)
4948

50-
err := printer.Print(context.Background(), issues)
49+
err := printer.Print(issues)
5150
require.NoError(t, err)
5251

5352
expected := `::warning file=path/to/filea.go,line=10,col=4::some issue (linter-a)

pkg/printers/html.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"fmt"
65
"html/template"
76
"io"
@@ -131,7 +130,7 @@ func NewHTML(w io.Writer) *HTML {
131130
return &HTML{w: w}
132131
}
133132

134-
func (p HTML) Print(_ context.Context, issues []result.Issue) error {
133+
func (p HTML) Print(issues []result.Issue) error {
135134
var htmlIssues []htmlIssue
136135

137136
for i := range issues {

pkg/printers/html_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -153,7 +152,7 @@ func TestHTML_Print(t *testing.T) {
153152
buf := new(bytes.Buffer)
154153
printer := NewHTML(buf)
155154

156-
err := printer.Print(context.Background(), issues)
155+
err := printer.Print(issues)
157156
require.NoError(t, err)
158157

159158
assert.Equal(t, expectedHTML, buf.String())

pkg/printers/json.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"encoding/json"
65
"io"
76

@@ -26,7 +25,7 @@ type JSONResult struct {
2625
Report *report.Data
2726
}
2827

29-
func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
28+
func (p JSON) Print(issues []result.Issue) error {
3029
res := JSONResult{
3130
Issues: issues,
3231
Report: p.rd,

pkg/printers/json_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -47,7 +46,7 @@ func TestJSON_Print(t *testing.T) {
4746

4847
printer := NewJSON(nil, buf)
4948

50-
err := printer.Print(context.Background(), issues)
49+
err := printer.Print(issues)
5150
require.NoError(t, err)
5251

5352
//nolint:lll

pkg/printers/junitxml.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"encoding/xml"
65
"fmt"
76
"io"
@@ -45,7 +44,7 @@ func NewJunitXML(w io.Writer) *JunitXML {
4544
return &JunitXML{w: w}
4645
}
4746

48-
func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error {
47+
func (p JunitXML) Print(issues []result.Issue) error {
4948
suites := make(map[string]testSuiteXML) // use a map to group by file
5049

5150
for ind := range issues {

pkg/printers/junitxml_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package printers
33

44
import (
55
"bytes"
6-
"context"
76
"go/token"
87
"testing"
98

@@ -47,7 +46,7 @@ func TestJunitXML_Print(t *testing.T) {
4746
buf := new(bytes.Buffer)
4847
printer := NewJunitXML(buf)
4948

50-
err := printer.Print(context.Background(), issues)
49+
err := printer.Print(issues)
5150
require.NoError(t, err)
5251

5352
expected := `<testsuites>

pkg/printers/printer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package printers
22

33
import (
4-
"context"
5-
64
"github.com/golangci/golangci-lint/pkg/result"
75
)
86

97
type Printer interface {
10-
Print(ctx context.Context, issues []result.Issue) error
8+
Print(issues []result.Issue) error
119
}

pkg/printers/tab.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"fmt"
65
"io"
76
"text/tabwriter"
@@ -31,7 +30,7 @@ func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) str
3130
return c.Sprintf(format, args...)
3231
}
3332

34-
func (p *Tab) Print(ctx context.Context, issues []result.Issue) error {
33+
func (p *Tab) Print(issues []result.Issue) error {
3534
w := tabwriter.NewWriter(p.w, 0, 0, 2, ' ', 0)
3635

3736
for i := range issues {

pkg/printers/tab_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -48,7 +47,7 @@ func TestTab_Print(t *testing.T) {
4847

4948
printer := NewTab(true, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
5049

51-
err := printer.Print(context.Background(), issues)
50+
err := printer.Print(issues)
5251
require.NoError(t, err)
5352

5453
expected := `path/to/filea.go:10:4 linter-a some issue

pkg/printers/teamcity.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"fmt"
65
"io"
76
"strings"
@@ -38,7 +37,7 @@ func NewTeamCity(w io.Writer) *TeamCity {
3837
}
3938
}
4039

41-
func (p *TeamCity) Print(_ context.Context, issues []result.Issue) error {
40+
func (p *TeamCity) Print(issues []result.Issue) error {
4241
uniqLinters := map[string]struct{}{}
4342

4443
for i := range issues {

pkg/printers/teamcity_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -54,7 +53,7 @@ func TestTeamCity_Print(t *testing.T) {
5453
buf := new(bytes.Buffer)
5554
printer := NewTeamCity(buf)
5655

57-
err := printer.Print(context.Background(), issues)
56+
err := printer.Print(issues)
5857
require.NoError(t, err)
5958

6059
expected := `##teamcity[InspectionType id='linter-a' name='linter-a' description='linter-a' category='Golangci-lint reports']

pkg/printers/text.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package printers
22

33
import (
4-
"context"
54
"fmt"
65
"io"
76
"strings"
@@ -40,7 +39,7 @@ func (p *Text) SprintfColored(ca color.Attribute, format string, args ...any) st
4039
return c.Sprintf(format, args...)
4140
}
4241

43-
func (p *Text) Print(ctx context.Context, issues []result.Issue) error {
42+
func (p *Text) Print(issues []result.Issue) error {
4443
for i := range issues {
4544
p.printIssue(&issues[i])
4645

pkg/printers/text_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package printers
22

33
import (
44
"bytes"
5-
"context"
65
"go/token"
76
"testing"
87

@@ -48,7 +47,7 @@ func TestText_Print(t *testing.T) {
4847

4948
printer := NewText(true, false, true, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
5049

51-
err := printer.Print(context.Background(), issues)
50+
err := printer.Print(issues)
5251
require.NoError(t, err)
5352

5453
expected := `path/to/filea.go:10:4: some issue (linter-a)

0 commit comments

Comments
 (0)