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

This commit is contained in:
Oleksandr Redko 2023-01-21 15:20:05 +02:00 committed by GitHub
parent d5d671f0bf
commit d19398964c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 19 deletions

View File

@ -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...)
}
@ -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)

View File

@ -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...)
}
@ -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)
@ -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)
}

View File

@ -32,7 +32,7 @@ func NewAutogeneratedExclude() *AutogeneratedExclude {
var _ Processor = &AutogeneratedExclude{}
func (p AutogeneratedExclude) Name() string {
func (p *AutogeneratedExclude) Name() string {
return "autogenerated_exclude"
}
@ -130,4 +130,4 @@ func getDoc(filePath string) (string, error) {
return strings.Join(docLines, "\n"), nil
}
func (p AutogeneratedExclude) Finish() {}
func (p *AutogeneratedExclude) Finish() {}

View File

@ -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"
}
@ -128,4 +128,4 @@ func (p *FilenameUnadjuster) Process(issues []result.Issue) ([]result.Issue, err
}), nil
}
func (FilenameUnadjuster) Finish() {}
func (p *FilenameUnadjuster) Finish() {}

View File

@ -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"
}
@ -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",

View File

@ -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"
}
@ -56,4 +56,4 @@ func (p *MaxPerFileFromLinter) Process(issues []result.Issue) ([]result.Issue, e
}), nil
}
func (p MaxPerFileFromLinter) Finish() {}
func (p *MaxPerFileFromLinter) Finish() {}

View File

@ -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"
}
@ -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",

View File

@ -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"
}
@ -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
}

View File

@ -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"
}
@ -55,4 +55,4 @@ func (p *UniqByLine) Process(issues []result.Issue) ([]result.Issue, error) {
}), nil
}
func (p UniqByLine) Finish() {}
func (p *UniqByLine) Finish() {}