Skip to content

Commit 37932d1

Browse files
authored
chore: remove dead code (#5801)
1 parent 522c98c commit 37932d1

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

pkg/golinters/dupl/dupl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I
7070
dupl := fmt.Sprintf("%s:%d-%d", toFilename, i.To.LineStart(), i.To.LineEnd())
7171
text := fmt.Sprintf("%d-%d lines are duplicate of %s",
7272
i.From.LineStart(), i.From.LineEnd(),
73-
internal.FormatCode(dupl, nil))
73+
internal.FormatCode(dupl))
7474

7575
res = append(res, goanalysis.NewIssue(&result.Issue{
7676
Pos: token.Position{

pkg/golinters/errcheck/errcheck.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
3737
checker.Tags = lintCtx.Cfg.Run.BuildTags
3838

3939
analyzer.Run = func(pass *analysis.Pass) (any, error) {
40-
issues := runErrCheck(lintCtx, pass, checker)
40+
issues := runErrCheck(pass, checker)
4141

4242
if len(issues) == 0 {
4343
return nil, nil
@@ -56,7 +56,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter {
5656
WithLoadMode(goanalysis.LoadModeTypesInfo)
5757
}
5858

59-
func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue {
59+
func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue {
6060
pkg := &packages.Package{
6161
Fset: pass.Fset,
6262
Syntax: pass.Files,
@@ -77,7 +77,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck
7777
if err.FuncName != "" {
7878
code := cmp.Or(err.SelectorName, err.FuncName)
7979

80-
text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code, lintCtx.Cfg))
80+
text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code))
8181
}
8282

8383
issues[i] = goanalysis.NewIssue(

pkg/golinters/gochecknoinits/gochecknoinits.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func run(pass *analysis.Pass) (any, error) {
4040

4141
fnName := funcDecl.Name.Name
4242
if fnName == "init" && funcDecl.Recv.NumFields() == 0 {
43-
pass.Reportf(funcDecl.Pos(), "don't use %s function", internal.FormatCode(fnName, nil))
43+
pass.Reportf(funcDecl.Pos(), "don't use %s function", internal.FormatCode(fnName))
4444
}
4545
})
4646

pkg/golinters/gocognit/gocognit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana
6767
issues = append(issues, goanalysis.NewIssue(&result.Issue{
6868
Pos: s.Pos,
6969
Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)",
70-
s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity),
70+
s.Complexity, internal.FormatCode(s.FuncName), settings.MinComplexity),
7171
FromLinter: linterName,
7272
}, pass))
7373
}

pkg/golinters/goconst/goconst.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal
8585

8686
switch {
8787
case issue.OccurrencesCount > 0:
88-
text = fmt.Sprintf("string %s has %d occurrences", internal.FormatCode(issue.Str, nil), issue.OccurrencesCount)
88+
text = fmt.Sprintf("string %s has %d occurrences", internal.FormatCode(issue.Str), issue.OccurrencesCount)
8989

9090
if issue.MatchingConst == "" {
9191
text += ", make it a constant"
9292
} else {
93-
text += fmt.Sprintf(", but such constant %s already exists", internal.FormatCode(issue.MatchingConst, nil))
93+
text += fmt.Sprintf(", but such constant %s already exists", internal.FormatCode(issue.MatchingConst))
9494
}
9595

9696
case issue.DuplicateConst != "":
9797
text = fmt.Sprintf("This constant is a duplicate of %s at %s",
98-
internal.FormatCode(issue.DuplicateConst, nil),
98+
internal.FormatCode(issue.DuplicateConst),
9999
issue.DuplicatePos.String())
100100

101101
default:

pkg/golinters/gocyclo/gocyclo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanaly
5959

6060
for _, s := range stats {
6161
text := fmt.Sprintf("cyclomatic complexity %d of func %s is high (> %d)",
62-
s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity)
62+
s.Complexity, internal.FormatCode(s.FuncName), settings.MinComplexity)
6363

6464
issues = append(issues, goanalysis.NewIssue(&result.Issue{
6565
Pos: s.Pos,

pkg/golinters/internal/util.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import (
66

77
"golang.org/x/tools/go/analysis"
88

9-
"github.com/golangci/golangci-lint/v2/pkg/config"
109
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
1110
)
1211

13-
func FormatCode(code string, _ *config.Config) string {
12+
func FormatCode(code string) string {
1413
if strings.Contains(code, "`") {
1514
return code // TODO: properly escape or remove
1615
}

pkg/golinters/prealloc/prealloc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) {
3131
for _, hint := range hints {
3232
pass.Report(analysis.Diagnostic{
3333
Pos: hint.Pos,
34-
Message: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)),
34+
Message: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName)),
3535
})
3636
}
3737
}

0 commit comments

Comments
 (0)