Skip to content

Commit 294ebfa

Browse files
authored
Update golangci-lint to v2.8.0 and fix linting issues (#986)
* Update golangci-lint to v2.8.0 and fix linting issues * Fix golangci-lint installation by using v2 module path
1 parent 71be6bf commit 294ebfa

File tree

12 files changed

+23
-22
lines changed

12 files changed

+23
-22
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
# Do not let tools interfere with the main module's go.mod.
9797
cd && go mod init tools
9898
go install honnef.co/go/tools/cmd/staticcheck@2025.1.1
99-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7
99+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0
100100
# Add PATH for installed tools.
101101
echo "$GOPATH/bin:$PATH" >> $GITHUB_PATH
102102
@@ -189,7 +189,7 @@ jobs:
189189
# Do not let tools interfere with the main module's go.mod.
190190
cd && go mod init tools
191191
go install honnef.co/go/tools/cmd/staticcheck@2025.1.1
192-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7
192+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0
193193
# Add PATH for installed tools.
194194
echo "$GOPATH/bin:$PATH" >> $GITHUB_PATH
195195

internal/binutils/binutils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func skipUnlessWindowsAmd64(t *testing.T) {
272272

273273
func testDisasm(t *testing.T, intelSyntax bool) {
274274
_, llvmObjdump, buObjdump := findObjdump([]string{""})
275-
if !(llvmObjdump || buObjdump) {
275+
if !llvmObjdump && !buObjdump {
276276
t.Skip("cannot disasm: no objdump tool available")
277277
}
278278

internal/driver/driver_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ func TestParse(t *testing.T) {
195195
if runtime.GOOS == "windows" {
196196
if flags[0] == "dot" {
197197
// The .dot test has the paths inside strings, so \ must be escaped.
198-
sbuf = bytes.Replace(sbuf, []byte("testdata/"), []byte(`testdata\\`), -1)
199-
sbuf = bytes.Replace(sbuf, []byte("/path/to/"), []byte(`\\path\\to\\`), -1)
198+
sbuf = bytes.ReplaceAll(sbuf, []byte("testdata/"), []byte(`testdata\\`))
199+
sbuf = bytes.ReplaceAll(sbuf, []byte("/path/to/"), []byte(`\\path\\to\\`))
200200
} else {
201-
sbuf = bytes.Replace(sbuf, []byte("testdata/"), []byte(`testdata\`), -1)
202-
sbuf = bytes.Replace(sbuf, []byte("/path/to/"), []byte(`\path\to\`), -1)
201+
sbuf = bytes.ReplaceAll(sbuf, []byte("testdata/"), []byte(`testdata\`))
202+
sbuf = bytes.ReplaceAll(sbuf, []byte("/path/to/"), []byte(`\path\to\`))
203203
}
204204
}
205205

internal/driver/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func configMenu(fname string, u url.URL) []configMenuEntry {
9090
result := make([]configMenuEntry, len(configs))
9191
lastMatch := -1
9292
for i, cfg := range configs {
93-
dst, changed := cfg.config.makeURL(u)
93+
dst, changed := cfg.makeURL(u)
9494
if !changed {
9595
lastMatch = i
9696
}

internal/driver/svg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
func massageSVG(svg string) string {
3434
// Work around for dot bug which misses quoting some ampersands,
3535
// resulting on unparsable SVG.
36-
svg = strings.Replace(svg, "&;", "&;", -1)
36+
svg = strings.ReplaceAll(svg, "&;", "&;")
3737

3838
// Dot's SVG output is
3939
//

internal/driver/webui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func dotToSvg(dot []byte) ([]byte, error) {
353353
}
354354

355355
// Fix dot bug related to unquoted ampersands.
356-
svg := bytes.Replace(out.Bytes(), []byte("&;"), []byte("&;"), -1)
356+
svg := bytes.ReplaceAll(out.Bytes(), []byte("&;"), []byte("&;"))
357357

358358
// Cleanup for embedding by dropping stuff before the <svg> start.
359359
if pos := bytes.Index(svg, []byte("<svg")); pos >= 0 {

internal/graph/dotgraph.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,11 @@ func dotColor(score float64, isBackground bool) string {
384384
func multilinePrintableName(info *NodeInfo) string {
385385
infoCopy := *info
386386
infoCopy.Name = escapeForDot(ShortenFunctionName(infoCopy.Name))
387-
infoCopy.Name = strings.Replace(infoCopy.Name, "::", `\n`, -1)
387+
infoCopy.Name = strings.ReplaceAll(infoCopy.Name, "::", `\n`)
388388
// Go type parameters are reported as "[...]" by Go pprof profiles.
389389
// Keep this ellipsis rather than replacing with newlines below.
390-
infoCopy.Name = strings.Replace(infoCopy.Name, "[...]", "[…]", -1)
391-
infoCopy.Name = strings.Replace(infoCopy.Name, ".", `\n`, -1)
390+
infoCopy.Name = strings.ReplaceAll(infoCopy.Name, "[...]", "[…]")
391+
infoCopy.Name = strings.ReplaceAll(infoCopy.Name, ".", `\n`)
392392
if infoCopy.File != "" {
393393
infoCopy.File = filepath.Base(infoCopy.File)
394394
}

internal/report/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func symbolsFromBinaries(prof *profile.Profile, g *graph.Graph, rx *regexp.Regex
535535
// the regexp (unless the regexp is an address and the mapping's range covers
536536
// the address)
537537
if !fileHasSamplesAndMatched[m.File] {
538-
if address == nil || !(m.Start <= *address && *address <= m.Limit) {
538+
if address == nil || m.Start > *address || *address > m.Limit {
539539
continue
540540
}
541541
}

internal/report/report_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ func TestSource(t *testing.T) {
8787
if runtime.GOOS == "windows" {
8888
if tc.rpt.options.OutputFormat == Dot {
8989
// The .dot test has the paths inside strings, so \ must be escaped.
90-
gold = bytes.Replace(gold, []byte("testdata/"), []byte(`testdata\\`), -1)
90+
gold = bytes.ReplaceAll(gold, []byte("testdata/"), []byte(`testdata\\`))
9191
} else {
92-
gold = bytes.Replace(gold, []byte("testdata/"), []byte(`testdata\`), -1)
92+
gold = bytes.ReplaceAll(gold, []byte("testdata/"), []byte(`testdata\`))
9393
}
9494
}
9595
if string(b.String()) != string(gold) {

internal/report/source.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,16 @@ func trimPath(path, trimPath, searchPath string) string {
10661066
func indentation(line string) int {
10671067
column := 0
10681068
for _, c := range line {
1069-
if c == ' ' {
1069+
switch c {
1070+
case ' ':
10701071
column++
1071-
} else if c == '\t' {
1072+
case '\t':
10721073
column++
10731074
for column%8 != 0 {
10741075
column++
10751076
}
1076-
} else {
1077-
break
1077+
default:
1078+
return column
10781079
}
10791080
}
10801081
return column

0 commit comments

Comments
 (0)