Skip to content

Commit 95e7710

Browse files
authored
build(linter): update linter to v1.64.5 and fix issues (hybridgroup#1130)
1 parent 514330e commit 95e7710

24 files changed

+86
-78
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
6262
"fmt_check_examples":
6363
docker:
64-
- image: golangci/golangci-lint:v1.61.0
64+
- image: golangci/golangci-lint:v1.64.5
6565
steps:
6666
- checkout
6767
- run:

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: golangci/golangci-lint-action@v6
2525
with:
2626
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
27-
version: v1.61.0
27+
version: v1.64.5
2828

2929
# Optional: working directory, useful for monorepos
3030
# working-directory: v2

.golangci.yml

+1-13
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,16 @@ issues:
3131
# note: folders/files can not be excluded from "typecheck" anymore since v1.61.0
3232

3333
linters:
34-
# currently active linters:
35-
#
36-
# INFO [lintersdb] Active 67 linters: [asasalint asciicheck bidichk bodyclose canonicalheader containedctx
37-
# contextcheck decorder depguard dogsled dupword durationcheck errcheck errchkjson errorlint fatcontext
38-
# forcetypeassert gci gocheckcompilerdirectives gochecknoinits gochecksumtype gocritic gofmt gofumpt goimports
39-
# gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper inamedparam ineffassign lll makezero
40-
# mirror misspell mnd musttag nakedret nilerr nilnil noctx nolintlint nonamedreturns nosprintfhostport perfsprint
41-
# prealloc predeclared protogetter reassign revive sloglint spancheck staticcheck tagalign tenv testableexamples
42-
# testifylint thelper tparallel unconvert unparam unused usestdlibvars wastedassign]
43-
4434
enable-all: true
4535

4636
# https://golangci-lint.run/usage/linters/#enabled-by-default
4737
# note: typecheck can not be disabled, it is used to check code compilation
4838
disable:
4939
# deprecated:
50-
- exportloopref # Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar
51-
- gomnd # The linter has been renamed. Replaced by mnd.
40+
- tenv # replaced by usetesting
5241
# not used for this go version: none
5342
# not used for any reason
5443
- err113 # not used (we allow error creation at return statement)
55-
- execinquery # not needed (no sql)
5644
- exhaustive # not used (we allow incomplete usage of enum switch, e.g. with default case)
5745
- forbidigo # not used (we allow print statements)
5846
- ginkgolinter # not needed (enforces standards of using ginkgo and gomega)

adaptor.go

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ type SpiSystemDevicer interface {
177177
}
178178

179179
// OneWireSystemDevicer is the interface to a 1-wire device at system level.
180+
//
181+
//nolint:iface // ok for now
180182
type OneWireSystemDevicer interface {
181183
// ID returns the device id in the form "family code"-"serial number".
182184
ID() string
@@ -230,6 +232,8 @@ type SpiOperations interface {
230232
}
231233

232234
// OneWireOperations are the wrappers around the actual functions used by the 1-wire device interface
235+
//
236+
//nolint:iface // ok for now
233237
type OneWireOperations interface {
234238
// ID returns the device id in the form "family code"-"serial number".
235239
ID() string

drivers/aio/analog_actuator_driver.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ func NewAnalogActuatorDriver(a AnalogWriter, pin string, opts ...interface{}) *A
6060
}
6161
}
6262

63+
//nolint:forcetypeassert // ok here
6364
d.AddCommand("Write", func(params map[string]interface{}) interface{} {
6465
val, err := strconv.ParseFloat(params["val"].(string), 64)
6566
if err != nil {
6667
return err
6768
}
6869
return d.Write(val)
6970
})
70-
71+
//nolint:forcetypeassert // ok here
7172
d.AddCommand("WriteRaw", func(params map[string]interface{}) interface{} {
7273
val, _ := strconv.Atoi(params["val"].(string))
7374
return d.WriteRaw(val)

drivers/aio/analog_sensor_driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ func NewAnalogSensorDriver(a AnalogReader, pin string, opts ...interface{}) *Ana
7777
}
7878
}
7979

80-
d.AddCommand("Read", func(params map[string]interface{}) interface{} {
80+
d.AddCommand("Read", func(_ map[string]interface{}) interface{} {
8181
val, err := d.Read()
8282
return map[string]interface{}{"val": val, "err": err}
8383
})
8484

85-
d.AddCommand("ReadRaw", func(params map[string]interface{}) interface{} {
85+
d.AddCommand("ReadRaw", func(_ map[string]interface{}) interface{} {
8686
val, err := d.ReadRaw()
8787
return map[string]interface{}{"val": val, "err": err}
8888
})

drivers/gpio/direct_pin_driver.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ func NewDirectPinDriver(a gobot.Connection, pin string, opts ...interface{}) *Di
2828
driver: newDriver(a, "DirectPin", append(opts, withPin(pin))...),
2929
}
3030

31-
d.AddCommand("DigitalRead", func(params map[string]interface{}) interface{} {
31+
d.AddCommand("DigitalRead", func(_ map[string]interface{}) interface{} {
3232
val, err := d.DigitalRead()
3333
return map[string]interface{}{"val": val, "err": err}
3434
})
35+
//nolint:forcetypeassert // ok here
3536
d.AddCommand("DigitalWrite", func(params map[string]interface{}) interface{} {
3637
level, _ := strconv.Atoi(params["level"].(string))
3738
return d.DigitalWrite(byte(level))
3839
})
40+
//nolint:forcetypeassert // ok here
3941
d.AddCommand("PwmWrite", func(params map[string]interface{}) interface{} {
4042
level, _ := strconv.Atoi(params["level"].(string))
4143
return d.PwmWrite(byte(level))
4244
})
45+
//nolint:forcetypeassert // ok here
4346
d.AddCommand("ServoWrite", func(params map[string]interface{}) interface{} {
4447
level, _ := strconv.Atoi(params["level"].(string))
4548
return d.ServoWrite(byte(level))

drivers/gpio/hcsr04_driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func NewHCSR04Driver(a gobot.Adaptor, triggerPinID, echoPinID string, opts ...in
8383
}
8484

8585
d.afterStart = func() error {
86-
tpin, err := a.(gobot.DigitalPinnerProvider).DigitalPin(triggerPinID)
86+
tpin, err := a.(gobot.DigitalPinnerProvider).DigitalPin(triggerPinID) //nolint:forcetypeassert // ok here
8787
if err != nil {
8888
return fmt.Errorf("error on get trigger pin: %v", err)
8989
}
@@ -93,7 +93,7 @@ func NewHCSR04Driver(a gobot.Adaptor, triggerPinID, echoPinID string, opts ...in
9393
d.triggerPin = tpin
9494

9595
// pins are inputs by default
96-
epin, err := a.(gobot.DigitalPinnerProvider).DigitalPin(echoPinID)
96+
epin, err := a.(gobot.DigitalPinnerProvider).DigitalPin(echoPinID) //nolint:forcetypeassert // ok here
9797
if err != nil {
9898
return fmt.Errorf("error on get echo pin: %v", err)
9999
}

drivers/gpio/led_driver.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ func NewLedDriver(a DigitalWriter, pin string, opts ...interface{}) *LedDriver {
2727
d := &LedDriver{
2828
driver: newDriver(a.(gobot.Connection), "LED", append(opts, withPin(pin))...),
2929
}
30-
30+
//nolint:forcetypeassert // ok here
3131
d.AddCommand("Brightness", func(params map[string]interface{}) interface{} {
32-
level := byte(params["level"].(float64)) //nolint:forcetypeassert // ok here
32+
level := byte(params["level"].(float64))
3333
return d.Brightness(level)
3434
})
3535

36-
d.AddCommand("Toggle", func(params map[string]interface{}) interface{} {
36+
d.AddCommand("Toggle", func(_ map[string]interface{}) interface{} {
3737
return d.Toggle()
3838
})
3939

40-
d.AddCommand("On", func(params map[string]interface{}) interface{} {
40+
d.AddCommand("On", func(_ map[string]interface{}) interface{} {
4141
return d.On()
4242
})
4343

44-
d.AddCommand("Off", func(params map[string]interface{}) interface{} {
44+
d.AddCommand("Off", func(_ map[string]interface{}) interface{} {
4545
return d.Off()
4646
})
4747

drivers/gpio/relay_driver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ func NewRelayDriver(a DigitalWriter, pin string, opts ...interface{}) *RelayDriv
5656
}
5757
}
5858

59-
d.AddCommand("Toggle", func(params map[string]interface{}) interface{} {
59+
d.AddCommand("Toggle", func(_ map[string]interface{}) interface{} {
6060
return d.Toggle()
6161
})
6262

63-
d.AddCommand("On", func(params map[string]interface{}) interface{} {
63+
d.AddCommand("On", func(_ map[string]interface{}) interface{} {
6464
return d.On()
6565
})
6666

67-
d.AddCommand("Off", func(params map[string]interface{}) interface{} {
67+
d.AddCommand("Off", func(_ map[string]interface{}) interface{} {
6868
return d.Off()
6969
})
7070

drivers/gpio/rgb_led_driver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func NewRgbLedDriver(a PwmWriter, redPin string, greenPin string, bluePin string
4545
return d.SetRGB(r, g, b)
4646
})
4747

48-
d.AddCommand("Toggle", func(params map[string]interface{}) interface{} {
48+
d.AddCommand("Toggle", func(_ map[string]interface{}) interface{} {
4949
return d.Toggle()
5050
})
5151

52-
d.AddCommand("On", func(params map[string]interface{}) interface{} {
52+
d.AddCommand("On", func(_ map[string]interface{}) interface{} {
5353
return d.On()
5454
})
5555

56-
d.AddCommand("Off", func(params map[string]interface{}) interface{} {
56+
d.AddCommand("Off", func(_ map[string]interface{}) interface{} {
5757
return d.Off()
5858
})
5959

drivers/gpio/servo_driver.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ func NewServoDriver(a ServoWriter, pin string, opts ...interface{}) *ServoDriver
3030
driver: newDriver(a.(gobot.Connection), "Servo", append(opts, withPin(pin))...),
3131
}
3232

33+
//nolint:forcetypeassert // ok here
3334
d.AddCommand("Move", func(params map[string]interface{}) interface{} {
34-
angle := byte(params["angle"].(float64)) //nolint:forcetypeassert // ok here
35+
angle := byte(params["angle"].(float64))
3536
return d.Move(angle)
3637
})
37-
d.AddCommand("ToMin", func(params map[string]interface{}) interface{} {
38+
d.AddCommand("ToMin", func(_ map[string]interface{}) interface{} {
3839
return d.ToMin()
3940
})
40-
d.AddCommand("ToCenter", func(params map[string]interface{}) interface{} {
41+
d.AddCommand("ToCenter", func(_ map[string]interface{}) interface{} {
4142
return d.ToCenter()
4243
})
43-
d.AddCommand("ToMax", func(params map[string]interface{}) interface{} {
44+
d.AddCommand("ToMax", func(_ map[string]interface{}) interface{} {
4445
return d.ToMax()
4546
})
4647

drivers/gpio/stepper_driver.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,29 @@ func NewStepperDriver(
117117
d.sleepFunc = d.sleepOuputs
118118
d.beforeHalt = d.shutdown
119119

120+
//nolint:forcetypeassert // ok here
120121
d.AddCommand("MoveDeg", func(params map[string]interface{}) interface{} {
121122
degs, _ := strconv.Atoi(params["degs"].(string))
122123
return d.MoveDeg(degs)
123124
})
125+
//nolint:forcetypeassert // ok here
124126
d.AddCommand("Move", func(params map[string]interface{}) interface{} {
125127
steps, _ := strconv.Atoi(params["steps"].(string))
126128
return d.Move(steps)
127129
})
128-
d.AddCommand("Step", func(params map[string]interface{}) interface{} {
130+
d.AddCommand("Step", func(_ map[string]interface{}) interface{} {
129131
return d.Move(1)
130132
})
131-
d.AddCommand("Run", func(params map[string]interface{}) interface{} {
133+
d.AddCommand("Run", func(_ map[string]interface{}) interface{} {
132134
return d.Run()
133135
})
134-
d.AddCommand("Sleep", func(params map[string]interface{}) interface{} {
136+
d.AddCommand("Sleep", func(_ map[string]interface{}) interface{} {
135137
return d.Sleep()
136138
})
137-
d.AddCommand("Stop", func(params map[string]interface{}) interface{} {
139+
d.AddCommand("Stop", func(_ map[string]interface{}) interface{} {
138140
return d.Stop()
139141
})
140-
d.AddCommand("Halt", func(params map[string]interface{}) interface{} {
142+
d.AddCommand("Halt", func(_ map[string]interface{}) interface{} {
141143
return d.Halt()
142144
})
143145

drivers/i2c/ads1x15_driver.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ func newADS1x15Driver(c Connector, name string, drs map[int]uint16, ddr int, opt
112112
option(d)
113113
}
114114

115+
//nolint:forcetypeassert // ok here
115116
d.AddCommand("ReadDifferenceWithDefaults", func(params map[string]interface{}) interface{} {
116-
channel := params["channel"].(int) //nolint:forcetypeassert // ok here
117+
channel := params["channel"].(int)
117118
val, err := d.ReadDifferenceWithDefaults(channel)
118119
return map[string]interface{}{"val": val, "err": err}
119120
})
@@ -127,8 +128,9 @@ func newADS1x15Driver(c Connector, name string, drs map[int]uint16, ddr int, opt
127128
return map[string]interface{}{"val": val, "err": err}
128129
})
129130

131+
//nolint:forcetypeassert // ok here
130132
d.AddCommand("ReadWithDefaults", func(params map[string]interface{}) interface{} {
131-
channel := params["channel"].(int) //nolint:forcetypeassert // ok here
133+
channel := params["channel"].(int)
132134
val, err := d.ReadWithDefaults(channel)
133135
return map[string]interface{}{"val": val, "err": err}
134136
})
@@ -142,8 +144,9 @@ func newADS1x15Driver(c Connector, name string, drs map[int]uint16, ddr int, opt
142144
return map[string]interface{}{"val": val, "err": err}
143145
})
144146

147+
//nolint:forcetypeassert // ok here
145148
d.AddCommand("AnalogRead", func(params map[string]interface{}) interface{} {
146-
pin := params["pin"].(string) //nolint:forcetypeassert // ok here
149+
pin := params["pin"].(string)
147150
val, err := d.AnalogRead(pin)
148151
return map[string]interface{}{"val": val, "err": err}
149152
})

drivers/i2c/blinkm_driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ func NewBlinkMDriver(c Connector, options ...func(Config)) *BlinkMDriver {
4747
return b.Fade(red, green, blue)
4848
})
4949

50-
b.AddCommand("FirmwareVersion", func(params map[string]interface{}) interface{} {
50+
b.AddCommand("FirmwareVersion", func(_ map[string]interface{}) interface{} {
5151
version, err := b.FirmwareVersion()
5252
return map[string]interface{}{"version": version, "err": err}
5353
})
5454

55-
b.AddCommand("Color", func(params map[string]interface{}) interface{} {
55+
b.AddCommand("Color", func(_ map[string]interface{}) interface{} {
5656
color, err := b.Color()
5757
return map[string]interface{}{"color": color, "err": err}
5858
})

drivers/i2c/jhd1313m1_driver.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,30 @@ func NewJHD1313M1Driver(a Connector, options ...func(Config)) *JHD1313M1Driver {
107107
option(d)
108108
}
109109

110+
//nolint:forcetypeassert // ok here
110111
d.AddCommand("SetRGB", func(params map[string]interface{}) interface{} {
111112
r, _ := strconv.Atoi(params["r"].(string))
112113
g, _ := strconv.Atoi(params["g"].(string))
113114
b, _ := strconv.Atoi(params["b"].(string))
114115
return d.SetRGB(r, g, b)
115116
})
116-
d.AddCommand("Clear", func(params map[string]interface{}) interface{} {
117+
d.AddCommand("Clear", func(_ map[string]interface{}) interface{} {
117118
return d.Clear()
118119
})
119-
d.AddCommand("Home", func(params map[string]interface{}) interface{} {
120+
d.AddCommand("Home", func(_ map[string]interface{}) interface{} {
120121
return d.Home()
121122
})
123+
//nolint:forcetypeassert // ok here
122124
d.AddCommand("Write", func(params map[string]interface{}) interface{} {
123-
msg := params["msg"].(string) //nolint:forcetypeassert // ok here
125+
msg := params["msg"].(string)
124126
return d.Write(msg)
125127
})
128+
//nolint:forcetypeassert // ok here
126129
d.AddCommand("SetPosition", func(params map[string]interface{}) interface{} {
127130
pos, _ := strconv.Atoi(params["pos"].(string))
128131
return d.SetPosition(pos)
129132
})
133+
//nolint:forcetypeassert // ok here
130134
d.AddCommand("Scroll", func(params map[string]interface{}) interface{} {
131135
lr, _ := strconv.ParseBool(params["lr"].(string))
132136
return d.Scroll(lr)

drivers/i2c/pca9685_driver.go

+2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ func NewPCA9685Driver(c Connector, options ...func(Config)) *PCA9685Driver {
7373
val, _ := strconv.Atoi(params["val"].(string))
7474
return p.ServoWrite(pin, byte(val))
7575
})
76+
//nolint:forcetypeassert // ok here
7677
p.AddCommand("SetPWM", func(params map[string]interface{}) interface{} {
7778
channel, _ := strconv.Atoi(params["channel"].(string))
7879
on, _ := strconv.Atoi(params["on"].(string))
7980
off, _ := strconv.Atoi(params["off"].(string))
8081
return p.SetPWM(channel, uint16(on), uint16(off)) //nolint:gosec // TODO: fix later
8182
})
83+
//nolint:forcetypeassert // ok here
8284
p.AddCommand("SetPWMFreq", func(params map[string]interface{}) interface{} {
8385
freq, _ := strconv.ParseFloat(params["freq"].(string), 32)
8486
return p.SetPWMFreq(float32(freq))

drivers/i2c/pcf8583_driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func NewPCF8583Driver(c Connector, options ...func(Config)) *PCF8583Driver {
8787
err := d.WriteTime(val)
8888
return map[string]interface{}{"err": err}
8989
})
90-
d.AddCommand("ReadTime", func(params map[string]interface{}) interface{} {
90+
d.AddCommand("ReadTime", func(_ map[string]interface{}) interface{} {
9191
val, err := d.ReadTime()
9292
return map[string]interface{}{"val": val, "err": err}
9393
})
@@ -97,7 +97,7 @@ func NewPCF8583Driver(c Connector, options ...func(Config)) *PCF8583Driver {
9797
err := d.WriteCounter(val)
9898
return map[string]interface{}{"err": err}
9999
})
100-
d.AddCommand("ReadCounter", func(params map[string]interface{}) interface{} {
100+
d.AddCommand("ReadCounter", func(_ map[string]interface{}) interface{} {
101101
val, err := d.ReadCounter()
102102
return map[string]interface{}{"val": val, "err": err}
103103
})

0 commit comments

Comments
 (0)