Skip to content

Commit 2bc4808

Browse files
committed
refactor: golangci-lint v2
Signed-off-by: Christian Stewart <[email protected]>
1 parent 60f9ed9 commit 2bc4808

File tree

27 files changed

+150
-146
lines changed

27 files changed

+150
-146
lines changed

.golangci.yml

+73-50
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,90 @@
1+
# Config file version V2 has been introduced, read more in lintersdb.
2+
# Visit https://golangci-lint.run/usage/configuration/#config-file
3+
version: "2"
4+
5+
# Settings for the `run` command.
6+
run:
7+
# Concurrency defines how many analyses can run simultaneously.
8+
# Default is 1.
9+
concurrency: 4
10+
# Modules-download-mode specifies how to download modules.
11+
# Allowed values: readonly, vendor, mod. Default is readonly.
12+
modules-download-mode: vendor
13+
14+
# Linters configuration.
115
linters:
216
enable:
317
- depguard
4-
- goimports
518
- gosec
6-
- gosimple
7-
- govet
819
- importas
9-
- ineffassign
1020
- misspell
1121
- revive
12-
- staticcheck
13-
- typecheck
1422
- unconvert
15-
- unused
16-
1723
disable:
1824
- errcheck
25+
settings:
26+
depguard:
27+
rules:
28+
main:
29+
deny:
30+
- pkg: io/ioutil
31+
desc: The io/ioutil package has been deprecated, see https://go.dev/doc/go1.16#ioutil
32+
- pkg: "github.com/stretchr/testify/assert"
33+
desc: Use "gotest.tools/v3/assert" instead
34+
- pkg: "github.com/stretchr/testify/require"
35+
desc: Use "gotest.tools/v3/assert" instead
36+
- pkg: "github.com/stretchr/testify/suite"
37+
desc: Do not use
38+
gosec:
39+
excludes:
40+
- G306 # Allow WriteFile permissions to be 0644.
41+
importas:
42+
# Do not allow unaliased imports of aliased packages.
43+
no-unaliased: true
44+
revive:
45+
rules:
46+
- name: package-comments
47+
disabled: true
48+
staticcheck:
49+
# All SA checks are enabled by default, customize as needed.
50+
# Refer to https://staticcheck.io/docs/checks for check details.
51+
checks:
52+
- all
53+
- '-SA1012' # Allow passing nil contexts.
54+
- '-ST1003' # Example of disabling another check if needed
1955

20-
run:
21-
concurrency: 4
22-
modules-download-mode: vendor
23-
24-
skip-dirs:
25-
- hack
26-
27-
linters-settings:
28-
staticcheck:
29-
checks:
30-
- all
31-
- '-SA1012' # Allow passing nil contexts.
32-
33-
importas:
34-
# Do not allow unaliased imports of aliased packages.
35-
no-unaliased: true
36-
37-
maligned:
38-
suggest-new: true
39-
40-
depguard:
41-
rules:
42-
main:
43-
deny:
44-
- pkg: io/ioutil
45-
desc: The io/ioutil package has been deprecated, see https://go.dev/doc/go1.16#ioutil
46-
- pkg: "github.com/stretchr/testify/assert"
47-
desc: Use "gotest.tools/v3/assert" instead
48-
- pkg: "github.com/stretchr/testify/require"
49-
desc: Use "gotest.tools/v3/assert" instead
50-
- pkg: "github.com/stretchr/testify/suite"
51-
desc: Do not use
52-
53-
revive:
54-
rules:
55-
- name: package-comments
56-
disabled: true
57-
58-
gosec:
59-
excludes:
60-
- G306 # Allow WriteFile permissions to be 0644.
56+
# Exclusions based on common patterns and presets.
57+
exclusions:
58+
# Treat generated files leniently.
59+
generated: lax
60+
# Use predefined sets of common exclusions.
61+
presets:
62+
- comments
63+
- common-false-positives
64+
- legacy # Excludes checks deprecated in new Go versions
65+
- std-error-handling # Excludes some common stdlib error patterns
66+
# Exclude specific paths using regex.
67+
paths:
68+
- third_party$
69+
- builtin$
70+
- examples$
6171

72+
# Issues reporting configuration.
6273
issues:
6374
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
6475
max-issues-per-linter: 0
65-
6676
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
6777
max-same-issues: 0
78+
79+
# Formatters configuration (new in V2).
80+
formatters:
81+
enable:
82+
- goimports # Enable goimports as a formatter.
83+
exclusions:
84+
# Treat generated files leniently for formatting.
85+
generated: lax
86+
# Exclude specific paths from formatting using regex.
87+
paths:
88+
- third_party$
89+
- builtin$
90+
- examples$

bus/api/api.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bus/api/api_srpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bus/api/controller/controller.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bus/inmem/inmem.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (b *Bus) RemoveController(c controller.Controller) {
113113
// addController adds a controller to the bus
114114
func (b *Bus) addController(c controller.Controller) error {
115115
b.mtx.Lock()
116-
rel, err := b.Controller.AddHandler(c)
116+
rel, err := b.AddHandler(c)
117117
if err == nil {
118118
b.controllers = append(b.controllers, &attachedCtrl{
119119
ctrl: c,

config/config.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55

66
protobuf_go_lite "github.com/aperturerobotics/protobuf-go-lite"
7-
vtcompare "github.com/aperturerobotics/protobuf-go-lite"
87
)
98

109
// Config is an object specifying configuration for a component of the system.
@@ -50,17 +49,17 @@ type Debuggable interface {
5049
}
5150

5251
// EqualsConfig implements EqualsConfig assuming both Config are the same type and have VTEqual.
53-
func EqualsConfig[T vtcompare.EqualVT[T]](t1 T, c2 Config) bool {
52+
func EqualsConfig[T protobuf_go_lite.EqualVT[T]](t1 T, c2 Config) bool {
5453
t2, ok := c2.(T)
5554
if !ok {
5655
return false
5756
}
58-
return vtcompare.IsEqualVT(t1, t2)
57+
return protobuf_go_lite.IsEqualVT(t1, t2)
5958
}
6059

6160
// IsEqualVT compares two objects with VTEqual.
62-
func IsEqualVT[T vtcompare.EqualVT[T]](c1, c2 T) bool {
63-
return vtcompare.IsEqualVT[T](c1, c2)
61+
func IsEqualVT[T protobuf_go_lite.EqualVT[T]](c1, c2 T) bool {
62+
return protobuf_go_lite.IsEqualVT[T](c1, c2)
6463
}
6564

6665
// MergeDebugVals merges multiple DebugValues into the first DebugValues passed.

config/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/configset/controller/apply-config-set.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (r *applyConfigSetResolver) Resolve(
9494
if v != 0 {
9595
handler.RemoveValue(v)
9696
}
97-
var val configset.ApplyConfigSetValue = st
97+
var val configset.ApplyConfigSetValue = st //nolint:staticcheck
9898
id, accepted := handler.AddValue(val)
9999
if accepted {
100100
r.refs[ref] = id

controller/configset/controller/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/configset/controller/lookup-config-set.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (r *lookupConfigSetResolver) Resolve(
9494
if v != 0 {
9595
handler.RemoveValue(v)
9696
}
97-
var val configset.LookupConfigSetValue = st
97+
var val configset.LookupConfigSetValue = st //nolint:staticcheck
9898
id, accepted := handler.AddValue(val)
9999
if accepted {
100100
r.refs[ref] = id

controller/configset/proto/configset.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/configset/proto/controller_config.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,18 @@ func (c *ControllerConfig) UnmarshalProtoJSON(s *json.UnmarshalState) {
156156
break
157157
}
158158
nextTok := s.WhatIsNext()
159-
if nextTok == jsoniter.StringValue {
159+
switch nextTok {
160+
case jsoniter.StringValue:
160161
// Expect base58 encoded string
161162
var err error
162163
c.Config, err = base64.RawStdEncoding.DecodeString(s.ReadString())
163164
if err != nil {
164165
s.SetError(errors.Wrap(err, "unmarshal config value as base58 string"))
165166
return
166167
}
167-
} else if nextTok == jsoniter.ObjectValue {
168+
case jsoniter.ObjectValue:
168169
c.Config = s.SkipAndReturnBytes()
169-
} else {
170+
default:
170171
s.SetError(errors.Errorf("invalid json value for config: type %v", nextTok))
171172
return
172173
}

controller/controller.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/exec/exec.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

directive/directive.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

directive/keyed-getter-resolver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (r *KeyedGetterResolver[K, V]) Resolve(ctx context.Context, handler Resolve
5858
return nil
5959
}
6060

61-
var result V = val
61+
var result V = val //nolint:staticcheck
6262
addedValID, accepted := handler.AddValue(result)
6363
if !accepted {
6464
// value not needed

example/boilerplate/controller/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/boilerplate/v1/boilerplate.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/hello-world/controller.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/plugin-demo/demo-controller/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ replace github.com/libp2p/go-msgio => github.com/aperturerobotics/go-libp2p-msgi
1111

1212
require (
1313
github.com/aperturerobotics/cli v1.0.0 // latest
14-
github.com/aperturerobotics/common v0.21.2 // latest
14+
github.com/aperturerobotics/common v0.22.1 // latest
1515
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20241223092408-d525fa878b3e // latest
1616
github.com/aperturerobotics/protobuf-go-lite v0.9.1 // latest
1717
github.com/aperturerobotics/starpc v0.38.0 // latest
18-
github.com/aperturerobotics/util v1.29.2 // latest
18+
github.com/aperturerobotics/util v1.30.0 // latest
1919
)
2020

2121
require (

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/aperturerobotics/cli v1.0.0 h1:s3xT2h7eBih4/4yZKTn/HQ6P+qpk6ygWZl2416xAI1M=
22
github.com/aperturerobotics/cli v1.0.0/go.mod h1:wtlINjMcKuwyV1x4ftReuA6hHZcPB8kPMXHyQqGFCSc=
3-
github.com/aperturerobotics/common v0.21.2 h1:fqnPL5Oovpd8nDaNBYGiD1UpZhcH/JfpsS8gt5iBDyA=
4-
github.com/aperturerobotics/common v0.21.2/go.mod h1:FrecdNcsYvVS8RcWCR8FUkKFh+XmouFOYKHpBdMqqBA=
3+
github.com/aperturerobotics/common v0.22.1 h1:wxTV9wSgfAM9jYUuSzNFzUeC28DQMBgDO3iGahlHeaY=
4+
github.com/aperturerobotics/common v0.22.1/go.mod h1:wsPfDVCTNpGHddg/MSfm84rKoO4GAvb+TQtATXz+pKY=
55
github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 h1:tGwbeDoEeQCrUQL+ClUywldqvz9eRmhcVrGwGxz2xJg=
66
github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0/go.mod h1:FJkAtQcP9XxqG1NNLNHKm+wLVIGSCQX2s6CEoD+w97g=
77
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20241223092408-d525fa878b3e h1:9KDK70CSnHCUGShpq3sEg/t8zEEnKePlhJ4775ekpeI=
@@ -10,8 +10,8 @@ github.com/aperturerobotics/protobuf-go-lite v0.9.1 h1:P1knXKnwLJpVE8fmeXYGckKu7
1010
github.com/aperturerobotics/protobuf-go-lite v0.9.1/go.mod h1:fULrxQxEBWKQm7vvju9AfjTp9yfHoLgwMQWTiZQ2tg0=
1111
github.com/aperturerobotics/starpc v0.38.0 h1:/1R3TLIoVIk5AA2SdCylykrL9BfoeTsXVvv8cRn0ebU=
1212
github.com/aperturerobotics/starpc v0.38.0/go.mod h1:hXOnhcvSXOoA6/Tw/qinQKhpi8+7WDkhrFXS5nHQ6us=
13-
github.com/aperturerobotics/util v1.29.2 h1:4mF7PfltK2g9KuD5gYUx3zvfEQXA/7F/V6EIEwJA35Q=
14-
github.com/aperturerobotics/util v1.29.2/go.mod h1:wfEm6n6evCQCGu+NjR8qINo0feaPEgeXxDZK6/oSuk8=
13+
github.com/aperturerobotics/util v1.30.0 h1:OKhFVPnAfR8/dfVNV27EtMr27C0kzwPiStoCwKiint0=
14+
github.com/aperturerobotics/util v1.30.0/go.mod h1:T97YTP+FVLegYo5rylOVaPuTLyZyiDqYxD5zVLI9YAc=
1515
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
1616
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
1717
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"singleQuote": true
4848
},
4949
"devDependencies": {
50-
"@aptre/common": "^0.21.1",
50+
"@aptre/common": "^0.22.1",
5151
"depcheck": "^1.4.7",
5252
"happy-dom": "^17.4.4",
5353
"prettier": "^3.5.3",
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@aptre/protobuf-es-lite": "^0.4.4",
60-
"starpc": "^0.38.0"
60+
"starpc": "^0.38.1"
6161
},
6262
"resolutions": {
6363
"@aptre/protobuf-es-lite": "0.4.8"

0 commit comments

Comments
 (0)