Skip to content

Commit 9d994d8

Browse files
committed
Upgrade golangci-lint to v2
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent a86f12c commit 9d994d8

6 files changed

Lines changed: 60 additions & 58 deletions

File tree

.arclint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
],
141141
"flags": [
142142
"--timeout=5m0s",
143-
"--out-format=checkstyle"
143+
"--output.checkstyle.path=stdout"
144144
]
145145
},
146146
"jshint-ui": {

.golangci.yaml

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,59 @@
11
---
2+
version: "2"
23
run:
3-
# Tell golangci-lint to not acquire a lock because
4-
# arcanist will run multiple instances in parallel.
54
allow-parallel-runners: true
6-
# arcanist runs many of these in parallel causing
7-
# CPU contention and longer runtimes.
8-
timeout: 3m
9-
10-
output:
11-
sort-results: true
12-
13-
issues:
14-
max-issues-per-linter: 0
15-
max-same-issues: 0
16-
# TODO(ddelnano): Remove once typecheck is upgraded in next golangci-lint upgrade
17-
# This error originates from the stdlib due to generics usage
18-
exclude-rules:
19-
- path: .*slices\/sort.go
20-
linters:
21-
- typecheck
22-
text: "^(undefined: (min|max))"
23-
245
linters:
256
enable:
267
- asciicheck
27-
- errcheck
28-
# Although goimports includes gofmt, it doesn't support the simplify option.
29-
# So we include gofmt here.
30-
- gofmt
31-
- gosimple
32-
- govet
33-
- ineffassign
348
- makezero
359
- misspell
3610
- nakedret
3711
- nolintlint
3812
- nonamedreturns
3913
- predeclared
4014
- revive
41-
- staticcheck
42-
# https://github.com/golangci/golangci-lint/issues/2649
43-
# - structcheck
44-
- typecheck
45-
- unused
46-
# https://github.com/golangci/golangci-lint/issues/2649
47-
# - wastedassign
4815
- whitespace
49-
disable:
50-
# The following linters are run separately by arcanist at the moment.
51-
# This is because we have autofix hooks for these linters.
52-
- goimports
53-
disable-all: false
54-
55-
linters-settings:
56-
errcheck:
57-
# yamllint disable-line rule:line-length
58-
ignore: io:Close,github.com/fatih/color,github.com/spf13/pflag:MarkHidden,github.com/spf13/viper:(BindEnv|BindPFlag),github.com/spf13/cobra:(Help|MarkFlagRequired|Usage),github.com/segmentio/analytics-go/v3:Enqueue,database/sql:Rollback,github.com/nats-io/nats.go:Unsubscribe
59-
goimports:
60-
local-prefixes: px.dev
61-
nakedret:
62-
max-func-lines: 0
16+
settings:
17+
errcheck:
18+
exclude-functions:
19+
- io.Close
20+
- github.com/spf13/pflag.MarkHidden
21+
- github.com/spf13/viper.BindEnv
22+
- github.com/spf13/viper.BindPFlag
23+
- github.com/spf13/cobra.Help
24+
- github.com/spf13/cobra.MarkFlagRequired
25+
- github.com/spf13/cobra.Usage
26+
- (github.com/segmentio/analytics-go/v3.Client).Enqueue
27+
- database/sql.Rollback
28+
- github.com/nats-io/nats.go.Unsubscribe
29+
staticcheck:
30+
checks:
31+
- all
32+
- "-ST1005" # ignore the "ST1005: error strings should not be capitalized" check
33+
exclusions:
34+
generated: lax
35+
presets:
36+
- comments
37+
- common-false-positives
38+
- legacy
39+
- std-error-handling
40+
paths:
41+
- third_party$
42+
- builtin$
43+
- examples$
44+
issues:
45+
max-issues-per-linter: 0
46+
max-same-issues: 0
47+
formatters:
48+
enable:
49+
- gofmt
50+
settings:
51+
goimports:
52+
local-prefixes:
53+
- px.dev
54+
exclusions:
55+
generated: lax
56+
paths:
57+
- third_party$
58+
- builtin$
59+
- examples$

docker.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DOCKER_IMAGE_TAG=202503281442
2-
LINTER_IMAGE_DIGEST=c88828fbc7844708ab8513ca9d8ecc1bcce937ebc6b6e7e54f254decaffcf845
3-
DEV_IMAGE_DIGEST=c8e30ba760cc1aec9fa4a009d3e93771544e2c376ed365a81100b840134e0327
4-
DEV_IMAGE_WITH_EXTRAS_DIGEST=4eb5646e63dff8ac3830b66ad261438a1d42cd5cfd40dbe87f6afd142d751cd0
1+
DOCKER_IMAGE_TAG=202504032251
2+
LINTER_IMAGE_DIGEST=8eec1d5c886ce15329612aae1ab7c827598733a3a7c16f0552dd75ae1efd3d21
3+
DEV_IMAGE_DIGEST=82345a12db00f8dcdd82108cf072da8abff6802646090c43d84ba2aabf0294b2
4+
DEV_IMAGE_WITH_EXTRAS_DIGEST=c73922e53e4e9dc37248b1fb2ccd7f4d092da488010485beac1b7bd19c97ee40

tools/arc_addons/pixielabs/lint/ArcanistGolangCiLinter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getInstallInstructions() {
4949
}
5050

5151
protected function getDefaultFlags() {
52-
return array('--out-format=checkstyle');
52+
return array('--output.text.path=stdout');
5353
}
5454

5555
protected function getPathArgumentForLinterFuture($path) {
@@ -95,6 +95,11 @@ protected function parseLinterOutput($path, $err, $stdout, $stderr) {
9595
return [$message];
9696
}
9797

98+
$lines = explode("\n", $stdout);
99+
// golangci-lint outputs a summary at the end of the output, which we
100+
// don't want to parse. See the example below:
101+
// 0 issues.
102+
$stdout = preg_replace('/\d+ issue(?:s)?\./', '', $stdout);
98103
$ok = @$report_dom->loadXML($stdout);
99104

100105
if (!$ok) {

tools/chef/cookbooks/px_dev/attributes/linux.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
'dea9ca38a0b852a74e81c26134671af7c0fbe65d81b0dc1c5bfe22cf7d4c8858'
3939

4040
default['golangci-lint']['download_path'] =
41-
'https://github.com/golangci/golangci-lint/releases/download/v1.51.1/golangci-lint-1.51.1-linux-amd64.tar.gz'
41+
'https://github.com/golangci/golangci-lint/releases/download/v2.0.2/golangci-lint-2.0.2-linux-amd64.tar.gz'
4242
default['golangci-lint']['sha256'] =
43-
'17aeb26c76820c22efa0e1838b0ab93e90cfedef43fbfc9a2f33f27eb9e5e070'
43+
'89cc8a7810dc63b9a37900da03e37c3601caf46d42265d774e0f1a5d883d53e2'
4444

4545
default['nodejs']['download_path'] =
4646
'https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-x64.tar.xz'

tools/chef/cookbooks/px_dev/attributes/mac_os_x.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
'7af054e5088b68c24b3d6e135e5ca8d91bbd5a05cb7f7f0187367b3e6e9e05ee'
4040

4141
default['golangci-lint']['download_path'] =
42-
'https://github.com/golangci/golangci-lint/releases/download/v1.51.1/golangci-lint-1.51.1-darwin-amd64.tar.gz'
42+
'https://github.com/golangci/golangci-lint/releases/download/v2.0.2/golangci-lint-2.0.2-darwin-amd64.tar.gz'
4343
default['golangci-lint']['sha256'] =
44-
'fba08acc4027f69f07cef48fbff70b8a7ecdfaa1c2aba9ad3fb31d60d9f5d4bc'
44+
'a88cbdc86b483fe44e90bf2dcc3fec2af8c754116e6edf0aa6592cac5baa7a0e'
4545

4646
default['nodejs']['download_path'] =
4747
'https://nodejs.org/dist/v18.16.0/node-v18.16.0-darwin-x64.tar.gz'

0 commit comments

Comments
 (0)