dev: remove unused ctx parameter from Printer (#3761)
This commit is contained in:
parent
8674597b84
commit
1948081d84
@ -71,6 +71,7 @@ linters-settings:
|
|||||||
rules:
|
rules:
|
||||||
- name: unexported-return
|
- name: unexported-return
|
||||||
disabled: true
|
disabled: true
|
||||||
|
- name: unused-parameter
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
|
@ -411,7 +411,7 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
|
|||||||
out = append(out, "")
|
out = append(out, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := e.printReports(ctx, issues, out[1], out[0])
|
err := e.printReports(issues, out[1], out[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -424,7 +424,7 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Executor) printReports(ctx context.Context, issues []result.Issue, path, format string) error {
|
func (e *Executor) printReports(issues []result.Issue, path, format string) error {
|
||||||
w, shouldClose, err := e.createWriter(path)
|
w, shouldClose, err := e.createWriter(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't create output for %s: %w", path, err)
|
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
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.Print(ctx, issues); err != nil {
|
if err = p.Print(issues); err != nil {
|
||||||
if file, ok := w.(io.Closer); shouldClose && ok {
|
if file, ok := w.(io.Closer); shouldClose && ok {
|
||||||
_ = file.Close()
|
_ = file.Close()
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,6 @@ func (l *tLog) Infof(format string, args ...any) {
|
|||||||
log.Printf(format, args...)
|
log.Printf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *tLog) Child(name string) logutils.Log { return nil }
|
func (l *tLog) Child(_ string) logutils.Log { return nil }
|
||||||
|
|
||||||
func (l *tLog) SetLevel(level logutils.LogLevel) {}
|
func (l *tLog) SetLevel(_ logutils.LogLevel) {}
|
||||||
|
@ -79,7 +79,7 @@ var enabledDebugs = getEnabledDebugs()
|
|||||||
|
|
||||||
type DebugFunc func(format string, args ...any)
|
type DebugFunc func(format string, args ...any)
|
||||||
|
|
||||||
func nopDebugf(format string, args ...any) {}
|
func nopDebugf(_ string, _ ...any) {}
|
||||||
|
|
||||||
func Debug(tag string) DebugFunc {
|
func Debug(tag string) DebugFunc {
|
||||||
if !enabledDebugs[tag] {
|
if !enabledDebugs[tag] {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -41,7 +40,7 @@ func NewCheckstyle(w io.Writer) *Checkstyle {
|
|||||||
return &Checkstyle{w: w}
|
return &Checkstyle{w: w}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Checkstyle) Print(ctx context.Context, issues []result.Issue) error {
|
func (p Checkstyle) Print(issues []result.Issue) error {
|
||||||
out := checkstyleOutput{
|
out := checkstyleOutput{
|
||||||
Version: "5.0",
|
Version: "5.0",
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -47,7 +46,7 @@ func TestCheckstyle_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewCheckstyle(buf)
|
printer := NewCheckstyle(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -35,7 +34,7 @@ func NewCodeClimate(w io.Writer) *CodeClimate {
|
|||||||
return &CodeClimate{w: w}
|
return &CodeClimate{w: w}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error {
|
func (p CodeClimate) Print(issues []result.Issue) error {
|
||||||
codeClimateIssues := make([]CodeClimateIssue, 0, len(issues))
|
codeClimateIssues := make([]CodeClimateIssue, 0, len(issues))
|
||||||
for i := range issues {
|
for i := range issues {
|
||||||
issue := &issues[i]
|
issue := &issues[i]
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ func TestCodeClimate_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewCodeClimate(buf)
|
printer := NewCodeClimate(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ func formatIssueAsGithub(issue *result.Issue) string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *github) Print(_ context.Context, issues []result.Issue) error {
|
func (p *github) Print(issues []result.Issue) error {
|
||||||
for ind := range issues {
|
for ind := range issues {
|
||||||
_, err := fmt.Fprintln(p.w, formatIssueAsGithub(&issues[ind]))
|
_, err := fmt.Fprintln(p.w, formatIssueAsGithub(&issues[ind]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,7 +3,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ func TestGithub_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewGithub(buf)
|
printer := NewGithub(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expected := `::warning file=path/to/filea.go,line=10,col=4::some issue (linter-a)
|
expected := `::warning file=path/to/filea.go,line=10,col=4::some issue (linter-a)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
@ -131,7 +130,7 @@ func NewHTML(w io.Writer) *HTML {
|
|||||||
return &HTML{w: w}
|
return &HTML{w: w}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p HTML) Print(_ context.Context, issues []result.Issue) error {
|
func (p HTML) Print(issues []result.Issue) error {
|
||||||
var htmlIssues []htmlIssue
|
var htmlIssues []htmlIssue
|
||||||
|
|
||||||
for i := range issues {
|
for i := range issues {
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ func TestHTML_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewHTML(buf)
|
printer := NewHTML(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, expectedHTML, buf.String())
|
assert.Equal(t, expectedHTML, buf.String())
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ type JSONResult struct {
|
|||||||
Report *report.Data
|
Report *report.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
|
func (p JSON) Print(issues []result.Issue) error {
|
||||||
res := JSONResult{
|
res := JSONResult{
|
||||||
Issues: issues,
|
Issues: issues,
|
||||||
Report: p.rd,
|
Report: p.rd,
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ func TestJSON_Print(t *testing.T) {
|
|||||||
|
|
||||||
printer := NewJSON(nil, buf)
|
printer := NewJSON(nil, buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -45,7 +44,7 @@ func NewJunitXML(w io.Writer) *JunitXML {
|
|||||||
return &JunitXML{w: w}
|
return &JunitXML{w: w}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error {
|
func (p JunitXML) Print(issues []result.Issue) error {
|
||||||
suites := make(map[string]testSuiteXML) // use a map to group by file
|
suites := make(map[string]testSuiteXML) // use a map to group by file
|
||||||
|
|
||||||
for ind := range issues {
|
for ind := range issues {
|
||||||
|
@ -3,7 +3,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ func TestJunitXML_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewJunitXML(buf)
|
printer := NewJunitXML(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expected := `<testsuites>
|
expected := `<testsuites>
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/result"
|
"github.com/golangci/golangci-lint/pkg/result"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Printer interface {
|
type Printer interface {
|
||||||
Print(ctx context.Context, issues []result.Issue) error
|
Print(issues []result.Issue) error
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
@ -39,7 +38,7 @@ func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) str
|
|||||||
return c.Sprintf(format, args...)
|
return c.Sprintf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Tab) Print(ctx context.Context, issues []result.Issue) error {
|
func (p *Tab) Print(issues []result.Issue) error {
|
||||||
w := tabwriter.NewWriter(p.w, 0, 0, 2, ' ', 0)
|
w := tabwriter.NewWriter(p.w, 0, 0, 2, ' ', 0)
|
||||||
|
|
||||||
for i := range issues {
|
for i := range issues {
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ path/to/fileb.go:300:9 another issue
|
|||||||
|
|
||||||
printer := NewTab(test.printLinterName, test.useColors, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
|
printer := NewTab(test.printLinterName, test.useColors, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, test.expected, buf.String())
|
assert.Equal(t, test.expected, buf.String())
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -38,7 +37,7 @@ func NewTeamCity(w io.Writer) *TeamCity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *TeamCity) Print(_ context.Context, issues []result.Issue) error {
|
func (p *TeamCity) Print(issues []result.Issue) error {
|
||||||
uniqLinters := map[string]struct{}{}
|
uniqLinters := map[string]struct{}{}
|
||||||
|
|
||||||
for i := range issues {
|
for i := range issues {
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ func TestTeamCity_Print(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
printer := NewTeamCity(buf)
|
printer := NewTeamCity(buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expected := `##teamcity[InspectionType id='linter-a' name='linter-a' description='linter-a' category='Golangci-lint reports']
|
expected := `##teamcity[InspectionType id='linter-a' name='linter-a' description='linter-a' category='Golangci-lint reports']
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package printers
|
package printers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -41,7 +40,7 @@ func (p *Text) SprintfColored(ca color.Attribute, format string, args ...any) st
|
|||||||
return c.Sprintf(format, args...)
|
return c.Sprintf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Text) Print(ctx context.Context, issues []result.Issue) error {
|
func (p *Text) Print(issues []result.Issue) error {
|
||||||
for i := range issues {
|
for i := range issues {
|
||||||
p.printIssue(&issues[i])
|
p.printIssue(&issues[i])
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package printers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ path/to/fileb.go:300:9: another issue
|
|||||||
|
|
||||||
printer := NewText(test.printIssuedLine, test.useColors, test.printLinterName, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
|
printer := NewText(test.printIssuedLine, test.useColors, test.printLinterName, logutils.NewStderrLog(logutils.DebugKeyEmpty), buf)
|
||||||
|
|
||||||
err := printer.Print(context.Background(), issues)
|
err := printer.Print(issues)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, test.expected, buf.String())
|
assert.Equal(t, test.expected, buf.String())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user