Skip to content

Commit 53a3b23

Browse files
committed
dev: remove unused ctx parameter from Printer
Also, enable revive `unused-parameter` rule for detecting this. And fix occurred issues in other files.
1 parent 5d34936 commit 53a3b23

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)

0 commit comments

Comments
 (0)