Skip to content

Commit 59acca4

Browse files
authored
chore!: upgrade lint & go (#649)
* chore: bump go to 1.23.3 and golangci-lint to 1.61.0 Signed-off-by: mikeee <[email protected]> * fix: ineffective nolint directive removed Signed-off-by: Mike Nguyen <[email protected]> * fix: perfsprint recommendations Signed-off-by: Mike Nguyen <[email protected]> * fix: intrange recommendations - refactor loops Signed-off-by: Mike Nguyen <[email protected]> * fix: remove existing dereferencing copies Signed-off-by: Mike Nguyen <[email protected]> * fix!: address gosec overflows BREAKING CHANGE: State consistency, concurrency and operation types are now int32 sized. Panic on an overflow conversion for a proto duration Signed-off-by: Mike Nguyen <[email protected]> * fix: tooling lint issues/ci update Signed-off-by: Mike Nguyen <[email protected]> * fix: perfsprint suggestions on dapr-bot Signed-off-by: Mike Nguyen <[email protected]> * chore(ci): remove gover remnants Signed-off-by: Mike Nguyen <[email protected]> * chore(ci): upgrade golangci-lint action version Signed-off-by: Mike Nguyen <[email protected]> --------- Signed-off-by: mikeee <[email protected]> Signed-off-by: Mike Nguyen <[email protected]>
1 parent 3fff121 commit 59acca4

File tree

26 files changed

+96
-138
lines changed

26 files changed

+96
-138
lines changed

.github/workflows/dapr-bot/bot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func (b *Bot) HandleEvent(ctx context.Context, event Event) (res string, err err
4949
switch command {
5050
case "/assign":
5151
assignee, err := b.AssignIssueToCommenter(event)
52-
res = fmt.Sprintf("👍 Issue assigned to %s", assignee)
52+
res = "👍 Issue assigned to " + assignee
5353
if err == nil {
54-
err = b.CreateIssueComment(fmt.Sprintf("🚀 Issue assigned to you @%s", assignee), event)
54+
err = b.CreateIssueComment("🚀 Issue assigned to you @"+assignee, event)
5555
} else {
5656
err = b.CreateIssueComment("⚠️ Unable to assign issue", event)
5757
}

.github/workflows/dapr-bot/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/dapr/go-sdk/.github/workflows/dapr-bot
22

3-
go 1.22
4-
5-
toolchain go1.22.0
3+
go 1.23.3
64

75
require (
86
github.com/google/go-github/v55 v55.0.0

.github/workflows/test-dapr-bot.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
name: Test
1818
runs-on: ubuntu-latest
1919
env:
20-
GOVER: ${{ matrix.gover }}
21-
GOLANGCILINT_VER: v1.55.2
20+
GOLANGCILINT_VER: v1.61.0
2221

2322
steps:
2423
- name: Checkout
@@ -38,7 +37,7 @@ jobs:
3837
run: make test
3938

4039
- name: Lint
41-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@v6
4241
with:
4342
version: ${{ env.GOLANGCILINT_VER }}
4443
working-directory: ./.github/workflows/dapr-bot

.github/workflows/test-on-push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88

99
jobs:
1010
build:
11-
name: Test on ${{ matrix.gover }}
11+
name: Test
1212
runs-on: ubuntu-latest
1313
env:
14-
GOLANGCILINT_VER: v1.55.2
14+
GOLANGCILINT_VER: v1.61.0
1515

1616
steps:
1717
- name: Checkout

.github/workflows/test-tooling.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
gover:
23-
- "1.21"
24-
- "1.22"
2522
os:
2623
- "ubuntu-latest"
2724
- "windows-latest"
2825
- "macos-latest"
2926
runs-on: ${{ matrix.os }}
3027
env:
31-
GOVER: ${{ matrix.gover }}
32-
GOLANGCILINT_VER: v1.55.2 # Make sure to bump /tools/check-lint-version/main_test.go
28+
GOLANGCILINT_VER: v1.61.0 # Make sure to bump /tools/check-lint-version/main_test.go
3329

3430
steps:
3531
- name: Checkout
@@ -38,7 +34,7 @@ jobs:
3834
- name: Setup
3935
uses: actions/setup-go@v5
4036
with:
41-
go-version: ${{ env.GOVER }}
37+
go-version-file: ./tools/check-lint-version/go.mod
4238

4339
- name: Tidy
4440
working-directory: ./tools/check-lint-version

.golangci.yml

Lines changed: 41 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run:
44
concurrency: 4
55

66
# timeout for analysis, e.g. 30s, 5m, default is 1m
7-
deadline: 10m
7+
timeout: 15m
88

99
# exit code when at least one issue was found, default is 1
1010
issues-exit-code: 1
@@ -13,31 +13,35 @@ run:
1313
tests: true
1414

1515
# list of build tags, all linters use it. Default is empty list.
16-
#build-tags:
17-
# - mytag
16+
build-tags:
17+
- unit
18+
- allcomponents
19+
- subtlecrypto
1820

21+
# which files to skip: they will be analyzed, but issues from them
22+
# won't be reported. Default value is empty list, but there is
23+
# no need to include all autogenerated files, we confidently recognize
24+
# autogenerated files. If it's not please let us know.
25+
# skip-files:
26+
# - ".*\\.my\\.go$"
27+
# - lib/bad.go
28+
29+
issues:
1930
# which dirs to skip: they won't be analyzed;
2031
# can use regexp here: generated.*, regexp is applied on full path;
2132
# default value is empty list, but next dirs are always skipped independently
2233
# from this option's value:
2334
# third_party$, testdata$, examples$, Godeps$, builtin$
24-
skip-dirs:
35+
exclude-dirs:
2536
- ^pkg.*client.*clientset.*versioned.*
2637
- ^pkg.*client.*informers.*externalversions.*
2738
- ^pkg.*proto.*
2839

29-
# which files to skip: they will be analyzed, but issues from them
30-
# won't be reported. Default value is empty list, but there is
31-
# no need to include all autogenerated files, we confidently recognize
32-
# autogenerated files. If it's not please let us know.
33-
# skip-files:
34-
# - ".*\\.my\\.go$"
35-
# - lib/bad.go
36-
3740
# output configuration options
3841
output:
3942
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
40-
format: tab
43+
formats:
44+
- format: tab
4145

4246
# print lines of code with issue, default is true
4347
print-issued-lines: true
@@ -57,23 +61,19 @@ linters-settings:
5761
# default is false: such cases aren't reported by default.
5862
check-blank: false
5963

60-
# [deprecated] comma-separated list of pairs of the form pkg:regex
61-
# the regex is used to ignore names within pkg. (default "fmt:.*").
62-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
63-
ignore: fmt:.*,io/ioutil:^Read.*
64+
exclude-functions:
65+
- fmt:.*
66+
- io/ioutil:^Read.*
6467

6568
# path to a file containing a list of functions to exclude from checking
6669
# see https://github.com/kisielk/errcheck#excluding-functions for details
67-
# exclude:
70+
# exclude:
6871

6972
funlen:
7073
lines: 60
7174
statements: 40
7275

7376
govet:
74-
# report about shadowed variables
75-
check-shadowing: true
76-
7777
# settings per analyzer
7878
settings:
7979
printf: # analyzer name, run `go tool vet help` to see all analyzers
@@ -86,28 +86,12 @@ linters-settings:
8686
# enable or disable analyzers by name
8787
enable:
8888
- atomicalign
89-
enable-all: false
90-
disable:
9189
- shadow
90+
enable-all: false
9291
disable-all: false
9392
revive:
94-
max-open-files: 2048
95-
# enable-all-rules: true
96-
rules:
97-
- name: cyclomatic
98-
severity: warning
99-
disabled: false
100-
arguments: [20]
101-
- name: argument-limit
102-
severity: warning
103-
disabled: false
104-
arguments: [8]
105-
- name: if-return
106-
severity: warning
107-
disabled: false
108-
- name: unused-parameter
109-
severity: warning
110-
disabled: true
93+
# minimal confidence for issues, default is 0.8
94+
confidence: 0.8
11195
gofmt:
11296
# simplify code: gofmt with `-s` option, true by default
11397
simplify: true
@@ -121,9 +105,6 @@ linters-settings:
121105
gocognit:
122106
# minimal code complexity to report, 30 by default (but we recommend 10-20)
123107
min-complexity: 10
124-
maligned:
125-
# print struct with more effective memory layout or not, false by default
126-
suggest-new: true
127108
dupl:
128109
# tokens count to trigger issue, 150 by default
129110
threshold: 100
@@ -152,10 +133,9 @@ linters-settings:
152133
desc: "you must use github.com/cenkalti/backoff/v4"
153134
misspell:
154135
# Correct spellings using locale preferences for US or UK.
155-
# Default is to use a neutral variety of English. (Do not specify a locale value)
136+
# Default is to use a neutral variety of English.
156137
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
157-
# locale:
158-
138+
# locale: default
159139
ignore-words:
160140
- someword
161141
lll:
@@ -164,12 +144,6 @@ linters-settings:
164144
line-length: 120
165145
# tab width in spaces. Default to 1.
166146
tab-width: 1
167-
unparam:
168-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
169-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
170-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
171-
# with golangci-lint call it on a directory with the changed file.
172-
check-exported: false
173147
nakedret:
174148
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
175149
max-func-lines: 30
@@ -187,7 +161,7 @@ linters-settings:
187161
# See https://go-critic.github.io/overview#checks-overview
188162
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
189163
# By default list of stable checks is used.
190-
# enabled-checks:
164+
# enabled-checks:
191165

192166
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
193167
disabled-checks:
@@ -235,17 +209,20 @@ linters-settings:
235209
allow-assign-and-call: true
236210
# Allow multiline assignments to be cuddled. Default is true.
237211
allow-multiline-assign: true
238-
# Allow case blocks to end with a whitespace.
239-
force-case-trailing-whitespace: 0
240212
# Allow declarations (var) to be cuddled.
241213
allow-cuddle-declarations: false
214+
# If the number of lines in a case block is equal to or lager than this number,
215+
# the case *must* end white a newline.
216+
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-case-trailing-whitespace
217+
# Default: 0
218+
force-case-trailing-whitespace: 1
242219

243220
linters:
244221
fast: false
245222
enable-all: true
246223
disable:
247224
# TODO Enforce the below linters later
248-
- nosnakecase
225+
- musttag
249226
- dupl
250227
- errcheck
251228
- funlen
@@ -254,26 +231,17 @@ linters:
254231
- gocyclo
255232
- gocognit
256233
- godox
257-
- interfacer
258234
- lll
259-
- maligned
260-
- scopelint
261235
- unparam
262236
- wsl
263237
- gomnd
264238
- testpackage
265-
- goerr113
266239
- nestif
267240
- nlreturn
268-
- tagliatelle
269-
- ifshort
270-
- forbidigo
271241
- exhaustive
272242
- exhaustruct
273-
- exhaustivestruct
274243
- noctx
275244
- gci
276-
- golint
277245
- tparallel
278246
- paralleltest
279247
- wrapcheck
@@ -287,7 +255,6 @@ linters:
287255
- varnamelen
288256
- errorlint
289257
- forcetypeassert
290-
- ifshort
291258
- maintidx
292259
- nilnil
293260
- predeclared
@@ -300,14 +267,12 @@ linters:
300267
- asasalint
301268
- rowserrcheck
302269
- sqlclosecheck
303-
- structcheck
304-
- varcheck
305-
- deadcode
306-
- golint
307270
- inamedparam
308-
issues:
309-
exclude-rules:
310-
- path: .*_test.go
311-
linters:
312-
- godot
313-
271+
- tagalign
272+
- mnd
273+
- canonicalheader
274+
- exportloopref
275+
- execinquery
276+
- err113
277+
- fatcontext
278+
- forbidigo # TODO: Re-enable and remove fmt.println

actor/manager/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ var ignoredActorMethods = []string{"Type"}
3737
// init initializes the action method exclusion list with methods from ServerImplBaseCtx and ReminderCallee interfaces.
3838
func init() {
3939
serverImplBaseCtxType := reflect.TypeOf(&actor.ServerImplBaseCtx{})
40-
for i := 0; i < serverImplBaseCtxType.NumMethod(); i++ {
40+
for i := range serverImplBaseCtxType.NumMethod() {
4141
ignoredActorMethods = append(ignoredActorMethods, serverImplBaseCtxType.Method(i).Name)
4242
}
4343
ReminderCallType := reflect.TypeOf((*actor.ReminderCallee)(nil)).Elem()
44-
for i := 0; i < ReminderCallType.NumMethod(); i++ {
44+
for i := range ReminderCallType.NumMethod() {
4545
ignoredActorMethods = append(ignoredActorMethods, ReminderCallType.Method(i).Name)
4646
}
4747
}
@@ -265,7 +265,7 @@ type MethodType struct {
265265
// suitableMethods returns suitable Rpc methods of typ.
266266
func suitableMethods(typ reflect.Type) map[string]*MethodType {
267267
methods := make(map[string]*MethodType)
268-
for m := 0; m < typ.NumMethod(); m++ {
268+
for m := range typ.NumMethod() {
269269
method := typ.Method(m)
270270
// skip methods from ServerImplBaseCtx struct and ServerContext and ReminderCallee interfaces.
271271
if slices.Contains(ignoredActorMethods, method.Name) {

actor/state/actor_state_change_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func TestNewActorStateChange(t *testing.T) {
4646
},
4747
}
4848
for name, test := range tests {
49-
test := test
5049
t.Run(name, func(t *testing.T) {
5150
assert.Equal(t, test.want, NewActorStateChange(test.stateName, test.value, test.changeKind, &test.ttl))
5251
})

client/actor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
289289
}
290290

291291
numField := valueOfActor.NumField()
292-
for i := 0; i < numField; i++ {
292+
for i := range numField {
293293
t := typeOfActor.Field(i)
294294
methodName := t.Name
295295
if methodName == "Type" {
@@ -312,7 +312,7 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
312312
}
313313

314314
funcOuts := make([]reflect.Type, outNum)
315-
for i := 0; i < outNum; i++ {
315+
for i := range outNum {
316316
funcOuts[i] = t.Type.Out(i)
317317
}
318318

client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func (s *testDaprServer) SubscribeConfiguration(in *pb.SubscribeConfigurationReq
466466
return err
467467
}
468468

469-
for i := 0; i < 5; i++ {
469+
for range 5 {
470470
select {
471471
case <-stopCh:
472472
return nil

0 commit comments

Comments
 (0)