Many staticcheck fixes

It now passes when run as:
  staticcheck -checks all,-U1000,-ST1003,-SA5002,-SA1019 ./...

The disabled checks will be enabled later since they are less trivial to
enable, as this is already a non-trivial number of modifications.
pull/1/head
Marc-Antoine Ruel 6 years ago
parent 18f5ca144b
commit 7682081ae0

@ -2,6 +2,7 @@
// Use of this source code is governed under the Apache License, Version 2.0 // Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package internal contains code shared between cci and lepton.
package internal package internal
import ( import (

@ -146,11 +146,13 @@ func (d *Dev) NextFrame(f *Frame) error {
if err := d.readFrame(f); err != nil { if err := d.readFrame(f); err != nil {
return err return err
} }
if f.Metadata.FFCDesired { /*
// TODO(maruel): Automatically trigger FFC when applicable, only do if if f.Metadata.FFCDesired {
// the camera has a shutter. // TODO(maruel): Automatically trigger FFC when applicable, only do if
//go d.RunFFC() // the camera has a shutter.
} go d.RunFFC()
}
*/
// Sadly the Lepton will unconditionally send 27fps, even if the effective // Sadly the Lepton will unconditionally send 27fps, even if the effective
// rate is 9fps. // rate is 9fps.
if !equalUint16(d.prevImg.Pix, f.Gray14.Pix) { if !equalUint16(d.prevImg.Pix, f.Gray14.Pix) {

@ -240,12 +240,12 @@ func (d *Dev) Halt() error {
d.cancel() d.cancel()
// A receive can always proceed on a closed channel we can use that // A receive can always proceed on a closed channel we can use that
// to signal that the running process has been canceled correctly. // to signal that the running process has been canceled correctly.
_, _ = <-d.done <-d.done
return nil return nil
} }
func (d *Dev) String() string { func (d *Dev) String() string {
return fmt.Sprintf("AMS AS7262 6 channel visible spectrum sensor") return "AMS AS7262 6 channel visible spectrum sensor"
} }
// Gain is the sensor gain for all bands // Gain is the sensor gain for all bands

@ -2,6 +2,7 @@
// Use of this source code is governed under the Apache License, Version 2.0 // Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package ina219smoketest tests the ina219 device.
package ina219smoketest package ina219smoketest
import ( import (

@ -54,7 +54,7 @@ func Example() {
log.Fatal(err) log.Fatal(err)
} }
if err := dev.Draw(img.Bounds(), img, image.ZP); err != nil { if err := dev.Draw(img.Bounds(), img, image.Point{}); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }

@ -57,7 +57,7 @@ func (c *Color) Set(s string) error {
case "white": case "white":
*c = White *c = White
default: default:
return fmt.Errorf("Unknown color %q: expected either black, red, yellow or white", s) return fmt.Errorf("unknown color %q: expected either black, red, yellow or white", s)
} }
return nil return nil
} }
@ -90,7 +90,7 @@ func (m *Model) Set(s string) error {
case "WHAT": case "WHAT":
*m = WHAT *m = WHAT
default: default:
return fmt.Errorf("Unknown model %q: expected either PHAT or WHAT", s) return fmt.Errorf("unknown model %q: expected either PHAT or WHAT", s)
} }
return nil return nil
} }
@ -278,7 +278,7 @@ func (d *Dev) Draw(dstRect image.Rectangle, src image.Image, srcPtrs image.Point
// DrawAll redraws the whole display. // DrawAll redraws the whole display.
func (d *Dev) DrawAll(src image.Image) error { func (d *Dev) DrawAll(src image.Image) error {
return d.Draw(d.Bounds(), src, image.ZP) return d.Draw(d.Bounds(), src, image.Point{})
} }
func (d *Dev) update(border byte, black []byte, red []byte) (err error) { func (d *Dev) update(border byte, black []byte, red []byte) (err error) {

@ -107,5 +107,5 @@ func (r *registerCache) getAndSetBit(bit uint8, value bool, cached bool) error {
func (r *registerCache) getBit(bit uint8, cached bool) (bool, error) { func (r *registerCache) getBit(bit uint8, cached bool) (bool, error) {
v, err := r.readValue(cached) v, err := r.readValue(cached)
return 0 != (v & (1 << bit)), err return (v & (1 << bit)) != 0, err
} }

@ -2,6 +2,7 @@
// Use of this source code is governed under the Apache License, Version 2.0 // Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package mcp9808smoketest implements a smoke test for the mcp9808.
package mcp9808smoketest package mcp9808smoketest
import ( import (

@ -2,6 +2,7 @@
// Use of this source code is governed under the Apache License, Version 2.0 // Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package accelerometer contains constants for the MPU9250.
package accelerometer package accelerometer
// Valid accelerator values. // Valid accelerator values.

@ -2,6 +2,7 @@
// Use of this source code is governed under the Apache License, Version 2.0 // Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
// Package reg defines constants for the MPU9250.
package reg package reg
// Unsorted mix of register addresses, commands and constants. // Unsorted mix of register addresses, commands and constants.

@ -125,7 +125,7 @@ func TestPCA9685(t *testing.T) {
func TestPCA9685_invalidCh(t *testing.T) { func TestPCA9685_invalidCh(t *testing.T) {
scenario := &i2ctest.Playback{ scenario := &i2ctest.Playback{
Ops: append(initializationSequence()), Ops: initializationSequence(),
} }
dev, err := NewI2C(scenario, I2CAddr) dev, err := NewI2C(scenario, I2CAddr)

@ -60,7 +60,7 @@ func (device *Dev) String() string {
// Halt sets all the pixels to black. Error is always nil. // Halt sets all the pixels to black. Error is always nil.
func (device *Dev) Halt() error { func (device *Dev) Halt() error {
black := color.RGBA{0, 0, 0, 0} black := color.RGBA{0, 0, 0, 0}
return device.Draw(device.Bounds(), &image.Uniform{black}, image.ZP) return device.Draw(device.Bounds(), &image.Uniform{black}, image.Point{})
} }
// ColorModel implements devices.Display. There's no surprise, it is // ColorModel implements devices.Display. There's no surprise, it is

@ -164,7 +164,7 @@ func TestDrawWritesBlackImageToSpi(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := New(spitest.NewRecordRaw(&buf)) dev, _ := New(spitest.NewRecordRaw(&buf))
black := color.RGBA{0, 0, 0, 0} black := color.RGBA{0, 0, 0, 0}
if err := dev.Draw(dev.Bounds(), &image.Uniform{black}, image.ZP); err != nil { if err := dev.Draw(dev.Bounds(), &image.Uniform{black}, image.Point{}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -219,7 +219,7 @@ func TestDrawWritesWhiteImageToSpi(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := New(spitest.NewRecordRaw(&buf)) dev, _ := New(spitest.NewRecordRaw(&buf))
white := color.RGBA{255, 255, 255, 255} white := color.RGBA{255, 255, 255, 255}
if err := dev.Draw(dev.Bounds(), &image.Uniform{white}, image.ZP); err != nil { if err := dev.Draw(dev.Bounds(), &image.Uniform{white}, image.Point{}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -291,7 +291,7 @@ func TestDrawWritesSequenceImageToSpi(t *testing.T) {
img.Set(x, y, clr) img.Set(x, y, clr)
} }
} }
if err := dev.Draw(dev.Bounds(), img, image.ZP); err != nil { if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -354,7 +354,7 @@ func TestDrawSupportsPartialUpdates(t *testing.T) {
buf := bytes.Buffer{} buf := bytes.Buffer{}
dev, _ := New(spitest.NewRecordRaw(&buf)) dev, _ := New(spitest.NewRecordRaw(&buf))
white := color.RGBA{0xFF, 0xFF, 0xFF, 0xFF} white := color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}
if err := dev.Draw(image.Rect(0, 0, 3, 3), &image.Uniform{white}, image.ZP); err != nil { if err := dev.Draw(image.Rect(0, 0, 3, 3), &image.Uniform{white}, image.Point{}); err != nil {
t.Fatal(err) t.Fatal(err)
} }

Loading…
Cancel
Save