build(linter): update linter to v1.56.1 and fix issues (#1068)
This commit is contained in:
parent
1a66f4b44d
commit
d76143ccb8
|
@ -61,7 +61,7 @@ jobs:
|
|||
|
||||
"fmt_check_examples":
|
||||
docker:
|
||||
- image: golangci/golangci-lint:v1.55.2
|
||||
- image: golangci/golangci-lint:v1.56.1
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
|
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
version: v1.55.2
|
||||
version: v1.56.1
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: v2
|
||||
|
|
|
@ -168,6 +168,14 @@ linters-settings:
|
|||
# Default: false
|
||||
require-specific: true
|
||||
|
||||
perfsprint:
|
||||
# Optimizes `fmt.Errorf`.
|
||||
# Default: true
|
||||
errorf: false
|
||||
# Optimizes `fmt.Sprintf` with only one argument
|
||||
# Default: true
|
||||
sprintf1: false
|
||||
|
||||
revive:
|
||||
rules:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
|
||||
|
|
|
@ -184,16 +184,17 @@ func TestTemperatureSensorWithSensorCyclicRead_PublishesError(t *testing.T) {
|
|||
func TestTemperatureSensorHalt_WithSensorCyclicRead(t *testing.T) {
|
||||
// arrange
|
||||
d := NewTemperatureSensorDriver(newAioTestAdaptor(), "1", WithSensorCyclicRead(10*time.Millisecond))
|
||||
done := make(chan struct{})
|
||||
require.NoError(t, d.Start())
|
||||
errChan := make(chan error, 1)
|
||||
// act & assert
|
||||
go func() {
|
||||
require.NoError(t, d.Halt())
|
||||
close(done)
|
||||
errChan <- d.Halt()
|
||||
}()
|
||||
|
||||
// test that the halt is not blocked by any deadlock with mutex and/or channel
|
||||
select {
|
||||
case <-done:
|
||||
case err := <-errChan:
|
||||
require.NoError(t, err)
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
require.Fail(t, "Temperature Sensor was not halted")
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestADS1x15CommandsReadDifferenceWithDefaults(t *testing.T) {
|
|||
result := d.Command("ReadDifferenceWithDefaults")(ads1x15TestChannel)
|
||||
// assert
|
||||
assert.Nil(t, result.(map[string]interface{})["err"])
|
||||
assert.Equal(t, -4.096, result.(map[string]interface{})["val"])
|
||||
assert.InDelta(t, -4.096, result.(map[string]interface{})["val"], 0.0)
|
||||
}
|
||||
|
||||
func TestADS1x15CommandsReadDifference(t *testing.T) {
|
||||
|
@ -61,7 +61,7 @@ func TestADS1x15CommandsReadDifference(t *testing.T) {
|
|||
result := d.Command("ReadDifference")(ads1x15TestChannelGainDataRate)
|
||||
// assert
|
||||
assert.Nil(t, result.(map[string]interface{})["err"])
|
||||
assert.Equal(t, -2.048, result.(map[string]interface{})["val"])
|
||||
assert.InDelta(t, -2.048, result.(map[string]interface{})["val"], 0.0)
|
||||
}
|
||||
|
||||
func TestADS1x15CommandsReadWithDefaults(t *testing.T) {
|
||||
|
@ -71,7 +71,7 @@ func TestADS1x15CommandsReadWithDefaults(t *testing.T) {
|
|||
result := d.Command("ReadWithDefaults")(ads1x15TestChannel)
|
||||
// assert
|
||||
assert.Nil(t, result.(map[string]interface{})["err"])
|
||||
assert.Equal(t, -4.096, result.(map[string]interface{})["val"])
|
||||
assert.InDelta(t, -4.096, result.(map[string]interface{})["val"], 0.0)
|
||||
}
|
||||
|
||||
func TestADS1x15CommandsRead(t *testing.T) {
|
||||
|
@ -81,7 +81,7 @@ func TestADS1x15CommandsRead(t *testing.T) {
|
|||
result := d.Command("Read")(ads1x15TestChannelGainDataRate)
|
||||
// assert
|
||||
assert.Nil(t, result.(map[string]interface{})["err"])
|
||||
assert.Equal(t, -2.048, result.(map[string]interface{})["val"])
|
||||
assert.InDelta(t, -2.048, result.(map[string]interface{})["val"], 0.0)
|
||||
}
|
||||
|
||||
func TestADS1x15CommandsAnalogRead(t *testing.T) {
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestWiichuckDriverCButton(t *testing.T) {
|
|||
done := make(chan bool)
|
||||
|
||||
_ = d.On(d.Event(C), func(data interface{}) {
|
||||
assert.Equal(t, true, data) //nolint:testifylint // data is an interface
|
||||
assert.Equal(t, true, data)
|
||||
done <- true
|
||||
})
|
||||
|
||||
|
@ -132,7 +132,7 @@ func TestWiichuckDriverZButton(t *testing.T) {
|
|||
done := make(chan bool)
|
||||
|
||||
_ = d.On(d.Event(Z), func(data interface{}) {
|
||||
assert.Equal(t, true, data) //nolint:testifylint // data is an interface
|
||||
assert.Equal(t, true, data)
|
||||
done <- true
|
||||
})
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ func main() {
|
|||
|
||||
case <-ticker.C:
|
||||
printAt(1, 0, "-- Press 'q' to Exit --")
|
||||
printAt(1, 1, fmt.Sprintf("Joystick Name: %s", js.Name()))
|
||||
printAt(1, 1, fmt.Sprintf("Joystick Name: %s", js.Name())) //nolint:perfsprint // ok here
|
||||
printAt(1, 2, fmt.Sprintf(" Axis Count: %d", js.AxisCount()))
|
||||
printAt(1, 3, fmt.Sprintf(" Button Count: %d", js.ButtonCount()))
|
||||
readJoystick(js)
|
||||
|
|
|
@ -189,8 +189,8 @@ func (j *Driver) initConfig() error {
|
|||
|
||||
func (j *Driver) initEvents() {
|
||||
for _, value := range j.config.Buttons {
|
||||
j.AddEvent(fmt.Sprintf("%s_press", value.Name))
|
||||
j.AddEvent(fmt.Sprintf("%s_release", value.Name))
|
||||
j.AddEvent(fmt.Sprintf("%s_press", value.Name)) //nolint:perfsprint // ok here
|
||||
j.AddEvent(fmt.Sprintf("%s_release", value.Name)) //nolint:perfsprint // ok here
|
||||
}
|
||||
for _, value := range j.config.Axis {
|
||||
j.AddEvent(value.Name)
|
||||
|
@ -214,9 +214,9 @@ func (j *Driver) handleButtons(state js.State) error {
|
|||
}
|
||||
|
||||
if buttonPressed {
|
||||
j.Publish(j.Event(fmt.Sprintf("%s_press", name)), nil)
|
||||
j.Publish(j.Event(fmt.Sprintf("%s_press", name)), nil) //nolint:perfsprint // ok here
|
||||
} else {
|
||||
j.Publish(j.Event(fmt.Sprintf("%s_release", name)), nil)
|
||||
j.Publish(j.Event(fmt.Sprintf("%s_release", name)), nil) //nolint:perfsprint // ok here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,6 @@ func (b *Bebop) Discover() error {
|
|||
data := make([]byte, 10240)
|
||||
|
||||
_, err = b.discoveryClient.Read(data)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -214,7 +213,6 @@ func (b *Bebop) Connect() error {
|
|||
}
|
||||
|
||||
b.c2dClient, err = net.DialUDP("udp", nil, c2daddr)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -55,8 +55,9 @@ func TestRobotStartAutoRun(t *testing.T) {
|
|||
// work,
|
||||
)
|
||||
|
||||
errChan := make(chan error, 1)
|
||||
go func() {
|
||||
require.NoError(t, r.Start())
|
||||
errChan <- r.Start() // if no strange things happen, this runs until os.signal occurs
|
||||
}()
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
@ -65,4 +66,10 @@ func TestRobotStartAutoRun(t *testing.T) {
|
|||
// stop it
|
||||
require.NoError(t, r.Stop())
|
||||
assert.False(t, r.Running())
|
||||
select {
|
||||
case err := <-errChan:
|
||||
require.NoError(t, err)
|
||||
case <-time.After(10 * time.Millisecond):
|
||||
// because the Start() will run forever, until os.Signal, this is ok here
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue