Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Do not use methods on pointer and value receivers #3321

Merged
merged 1 commit into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/printers/tab.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewTab(printLinterName bool, log logutils.Log, w io.Writer) *Tab {
}
}

func (p Tab) SprintfColored(ca color.Attribute, format string, args ...interface{}) string {
func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...interface{}) string {
c := color.New(ca)
return c.Sprintf(format, args...)
}
Expand All @@ -45,7 +45,7 @@ func (p *Tab) Print(ctx context.Context, issues []result.Issue) error {
return nil
}

func (p Tab) printIssue(i *result.Issue, w io.Writer) {
func (p *Tab) printIssue(i *result.Issue, w io.Writer) {
text := p.SprintfColored(color.FgRed, "%s", i.Text)
if p.printLinterName {
text = fmt.Sprintf("%s\t%s", i.FromLinter, text)
Expand Down
6 changes: 3 additions & 3 deletions pkg/printers/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewText(printIssuedLine, useColors, printLinterName bool, log logutils.Log,
}
}

func (p Text) SprintfColored(ca color.Attribute, format string, args ...interface{}) string {
func (p *Text) SprintfColored(ca color.Attribute, format string, args ...interface{}) string {
if !p.useColors {
return fmt.Sprintf(format, args...)
}
Expand All @@ -55,7 +55,7 @@ func (p *Text) Print(ctx context.Context, issues []result.Issue) error {
return nil
}

func (p Text) printIssue(i *result.Issue) {
func (p *Text) printIssue(i *result.Issue) {
text := p.SprintfColored(color.FgRed, "%s", strings.TrimSpace(i.Text))
if p.printLinterName {
text += fmt.Sprintf(" (%s)", i.FromLinter)
Expand All @@ -67,7 +67,7 @@ func (p Text) printIssue(i *result.Issue) {
fmt.Fprintf(p.w, "%s: %s\n", pos, text)
}

func (p Text) printSourceCode(i *result.Issue) {
func (p *Text) printSourceCode(i *result.Issue) {
for _, line := range i.SourceLines {
fmt.Fprintln(p.w, line)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/result/processors/autogenerated_exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewAutogeneratedExclude() *AutogeneratedExclude {

var _ Processor = &AutogeneratedExclude{}

func (p AutogeneratedExclude) Name() string {
func (p *AutogeneratedExclude) Name() string {
return "autogenerated_exclude"
}

Expand Down Expand Up @@ -130,4 +130,4 @@ func getDoc(filePath string) (string, error) {
return strings.Join(docLines, "\n"), nil
}

func (p AutogeneratedExclude) Finish() {}
func (p *AutogeneratedExclude) Finish() {}
4 changes: 2 additions & 2 deletions pkg/result/processors/filename_unadjuster.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func NewFilenameUnadjuster(pkgs []*packages.Package, log logutils.Log) *Filename
}
}

func (p FilenameUnadjuster) Name() string {
func (p *FilenameUnadjuster) Name() string {
return "filename_unadjuster"
}

Expand Down Expand Up @@ -128,4 +128,4 @@ func (p *FilenameUnadjuster) Process(issues []result.Issue) ([]result.Issue, err
}), nil
}

func (FilenameUnadjuster) Finish() {}
func (p *FilenameUnadjuster) Finish() {}
4 changes: 2 additions & 2 deletions pkg/result/processors/max_from_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewMaxFromLinter(limit int, log logutils.Log, cfg *config.Config) *MaxFromL
}
}

func (p MaxFromLinter) Name() string {
func (p *MaxFromLinter) Name() string {
return "max_from_linter"
}

Expand All @@ -44,7 +44,7 @@ func (p *MaxFromLinter) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}

func (p MaxFromLinter) Finish() {
func (p *MaxFromLinter) Finish() {
walkStringToIntMapSortedByValue(p.lc, func(linter string, count int) {
if count > p.limit {
p.log.Infof("%d/%d issues from linter %s were hidden, use --max-issues-per-linter",
Expand Down
4 changes: 2 additions & 2 deletions pkg/result/processors/max_per_file_from_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter {
}
}

func (p MaxPerFileFromLinter) Name() string {
func (p *MaxPerFileFromLinter) Name() string {
return "max_per_file_from_linter"
}

Expand All @@ -56,4 +56,4 @@ func (p *MaxPerFileFromLinter) Process(issues []result.Issue) ([]result.Issue, e
}), nil
}

func (p MaxPerFileFromLinter) Finish() {}
func (p *MaxPerFileFromLinter) Finish() {}
4 changes: 2 additions & 2 deletions pkg/result/processors/max_same_issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewMaxSameIssues(limit int, log logutils.Log, cfg *config.Config) *MaxSameI
}
}

func (MaxSameIssues) Name() string {
func (p *MaxSameIssues) Name() string {
return "max_same_issues"
}

Expand All @@ -48,7 +48,7 @@ func (p *MaxSameIssues) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}

func (p MaxSameIssues) Finish() {
func (p *MaxSameIssues) Finish() {
walkStringToIntMapSortedByValue(p.tc, func(text string, count int) {
if count > p.limit {
p.log.Infof("%d/%d issues with text %q were hidden, use --max-same-issues",
Expand Down
4 changes: 2 additions & 2 deletions pkg/result/processors/nolint.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewNolint(log logutils.Log, dbManager *lintersdb.Manager, enabledLinters ma

var _ Processor = &Nolint{}

func (p Nolint) Name() string {
func (p *Nolint) Name() string {
return "nolint"
}

Expand Down Expand Up @@ -284,7 +284,7 @@ func (p *Nolint) extractInlineRangeFromComment(text string, g ast.Node, fset *to
return buildRange(linters)
}

func (p Nolint) Finish() {
func (p *Nolint) Finish() {
if len(p.unknownLintersSet) == 0 {
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/result/processors/uniq_by_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewUniqByLine(cfg *config.Config) *UniqByLine {

var _ Processor = &UniqByLine{}

func (p UniqByLine) Name() string {
func (p *UniqByLine) Name() string {
return "uniq_by_line"
}

Expand Down Expand Up @@ -55,4 +55,4 @@ func (p *UniqByLine) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}

func (p UniqByLine) Finish() {}
func (p *UniqByLine) Finish() {}