diff --git a/.golangci.yml b/.golangci.yml index 76d253895..5d627559a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,7 +9,6 @@ linters: enable: - asciicheck - bodyclose - - contextcheck - durationcheck - errcheck - errorlint diff --git a/internal/board/calendar/render.go b/internal/board/calendar/render.go index e4ccf2852..e20a2d9e5 100644 --- a/internal/board/calendar/render.go +++ b/internal/board/calendar/render.go @@ -25,6 +25,7 @@ func (s *CalendarBoard) Render(ctx context.Context, canvas board.Canvas) error { } // Render ... +// nolint:contextcheck func (s *CalendarBoard) render(ctx context.Context, canvas board.Canvas) error { s.boardCtx, s.boardCancel = context.WithCancel(ctx) diff --git a/internal/board/image/http.go b/internal/board/image/http.go index 957b353f8..dded6c4bc 100644 --- a/internal/board/image/http.go +++ b/internal/board/image/http.go @@ -18,6 +18,8 @@ type jumpRequest struct { } // GetHTTPHandlers ... +// +//nolint:contextcheck func (i *ImageBoard) GetHTTPHandlers() ([]*board.HTTPHandler, error) { return []*board.HTTPHandler{ { diff --git a/internal/board/image/imageboard.go b/internal/board/image/imageboard.go index fc10878ed..d8395ffe7 100644 --- a/internal/board/image/imageboard.go +++ b/internal/board/image/imageboard.go @@ -393,7 +393,7 @@ IMAGES: if nextIndex < len(images) { if images[nextIndex].isGif { - pCtx, pCancel := context.WithTimeout(context.Background(), preloaderTimeout) + pCtx, pCancel := context.WithTimeout(ctx, preloaderTimeout) defer pCancel() wg.Add(1) go preloadGif(pCtx, images[nextIndex]) diff --git a/internal/board/image/util_test.go b/internal/board/image/util_test.go index cd8c068d9..b604deab6 100644 --- a/internal/board/image/util_test.go +++ b/internal/board/image/util_test.go @@ -7,6 +7,7 @@ import ( ) func TestFilenameCompare(t *testing.T) { + t.Parallel() tests := []struct { name string a string @@ -61,12 +62,14 @@ func TestFilenameCompare(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() require.Equal(t, test.expected, filenameCompare(test.a, test.b)) }) } } func TestReverseStrs(t *testing.T) { + t.Parallel() tests := []struct { name string in []string @@ -93,6 +96,7 @@ func TestReverseStrs(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() require.Equal(t, test.expected, reverseStrs(test.in)) }) } diff --git a/internal/board/racing/render.go b/internal/board/racing/render.go index b19e073d5..b33ab9ded 100644 --- a/internal/board/racing/render.go +++ b/internal/board/racing/render.go @@ -26,6 +26,8 @@ func (s *RacingBoard) Render(ctx context.Context, canvas board.Canvas) error { } // Render ... +// +//nolint:contextcheck func (s *RacingBoard) render(ctx context.Context, canvas board.Canvas) error { s.boardCtx, s.boardCancel = context.WithCancel(ctx) diff --git a/internal/board/sport/http.go b/internal/board/sport/http.go index b6357c724..b127eff24 100644 --- a/internal/board/sport/http.go +++ b/internal/board/sport/http.go @@ -11,6 +11,8 @@ import ( ) // GetHTTPHandlers ... +// +//nolint:contextcheck func (s *SportBoard) GetHTTPHandlers() ([]*board.HTTPHandler, error) { return []*board.HTTPHandler{ { diff --git a/internal/canvas/canvas_test.go b/internal/canvas/canvas_test.go index e4bfe8c01..4f81221c4 100644 --- a/internal/canvas/canvas_test.go +++ b/internal/canvas/canvas_test.go @@ -12,6 +12,7 @@ import ( ) func TestNewCanvas(t *testing.T) { + t.Parallel() canvas := NewCanvas(NewMatrixMock(64, 32)) require.NotNil(t, canvas) require.Equal(t, 64, canvas.w) @@ -19,6 +20,7 @@ func TestNewCanvas(t *testing.T) { } func TestRender(t *testing.T) { + t.Parallel() m := NewMatrixMock(10, 20) canvas := &Canvas{m: m} err := canvas.Render(context.Background()) @@ -26,11 +28,13 @@ func TestRender(t *testing.T) { } func TestColorModel(t *testing.T) { + t.Parallel() canvas := &Canvas{} require.Equal(t, color.RGBAModel, canvas.ColorModel()) } func TestBounds(t *testing.T) { + t.Parallel() canvas := &Canvas{w: 10, h: 20} b := canvas.Bounds() @@ -41,6 +45,7 @@ func TestBounds(t *testing.T) { } func TestSet(t *testing.T) { + t.Parallel() m := NewMatrixMock(10, 20) canvas := &Canvas{w: 10, h: 20, m: m} canvas.Set(5, 15, color.White) @@ -49,6 +54,7 @@ func TestSet(t *testing.T) { } func TestClear(t *testing.T) { + t.Parallel() m := NewMatrixMock(10, 20) canvas := &Canvas{w: 10, h: 20, m: m} @@ -61,6 +67,7 @@ func TestClear(t *testing.T) { } func TestClose(t *testing.T) { + t.Parallel() m := NewMatrixMock(10, 20) canvas := &Canvas{w: 10, h: 20, m: m} err := canvas.Close() @@ -85,7 +92,7 @@ func NewMatrixMock(w int, h int) *MatrixMock { } } -func (m *MatrixMock) Geometry() (width, height int) { +func (m *MatrixMock) Geometry() (int, int) { return 64, 32 } diff --git a/internal/espnboard/espnboard.go b/internal/espnboard/espnboard.go index 48262936f..af59694f8 100644 --- a/internal/espnboard/espnboard.go +++ b/internal/espnboard/espnboard.go @@ -74,6 +74,7 @@ func (e *ESPNBoard) logoCacheDir() (string, error) { } // New ... +// nolint:contextcheck func New(ctx context.Context, leaguer Leaguer, logger *zap.Logger, r rankSetter, rec rankSetter, opts ...Option) (*ESPNBoard, error) { e := &ESPNBoard{ leaguer: leaguer, diff --git a/internal/nhl/nhl.go b/internal/nhl/nhl.go index 52b5cc446..5c822b895 100644 --- a/internal/nhl/nhl.go +++ b/internal/nhl/nhl.go @@ -47,7 +47,7 @@ func New(ctx context.Context, logger *zap.Logger) (*NHL, error) { } c := cron.New() - if _, err := c.AddFunc("0 5 * * *", func() { n.CacheClear(context.Background()) }); err != nil { + if _, err := c.AddFunc("0 5 * * *", func() { n.CacheClear(ctx) }); err != nil { return n, fmt.Errorf("failed to set cron job for cacheClear: %w", err) } c.Start() diff --git a/internal/rgbrender/grid_test.go b/internal/rgbrender/grid_test.go index eb6c11aaa..21b7a54f2 100644 --- a/internal/rgbrender/grid_test.go +++ b/internal/rgbrender/grid_test.go @@ -57,6 +57,7 @@ func TestGridLayout(t *testing.T) { } func TestGrid(t *testing.T) { + t.Parallel() log, err := zap.NewDevelopment() require.NoError(t, err) canvas := board.NewBlankCanvas(100, 100, log) diff --git a/internal/rgbrender/layer_test.go b/internal/rgbrender/layer_test.go index 7d6b4fde1..11380ba8c 100644 --- a/internal/rgbrender/layer_test.go +++ b/internal/rgbrender/layer_test.go @@ -157,6 +157,7 @@ func TestPriorities(t *testing.T) { } func TestRender(t *testing.T) { + t.Parallel() layers, err := NewLayerDrawer(60*time.Second, nil) require.NoError(t, err) @@ -203,6 +204,7 @@ func TestRender(t *testing.T) { } func TestBadPrepare(t *testing.T) { + t.Parallel() layers, err := NewLayerDrawer(60*time.Second, nil) require.NoError(t, err) @@ -219,6 +221,7 @@ func TestBadPrepare(t *testing.T) { } func TestBadRender(t *testing.T) { + t.Parallel() layers, err := NewLayerDrawer(60*time.Second, nil) require.NoError(t, err) diff --git a/internal/rgbrender/rgbrender_test.go b/internal/rgbrender/rgbrender_test.go index 23eeec5e5..d274b61be 100644 --- a/internal/rgbrender/rgbrender_test.go +++ b/internal/rgbrender/rgbrender_test.go @@ -588,6 +588,7 @@ func TestZoomImageSize(t *testing.T) { } func TestNegativeImagePoint(t *testing.T) { + t.Parallel() i := image.NewRGBA(image.Rect(-10, -10, 10, 10)) i.Set(-5, -5, color.Gray16{0xffff}) diff --git a/internal/rgbrender/text_test.go b/internal/rgbrender/text_test.go index 6cadc1d44..f06f2d992 100644 --- a/internal/rgbrender/text_test.go +++ b/internal/rgbrender/text_test.go @@ -7,6 +7,7 @@ import ( ) func TestBreakText(t *testing.T) { + t.Parallel() tests := []struct { name string in string @@ -53,6 +54,7 @@ func TestBreakText(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() require.Equal(t, test.expected, breakText(test.max, test.in)) }) } diff --git a/internal/scrollcanvas/scroll_canvas_test.go b/internal/scrollcanvas/scroll_canvas_test.go index 77bfe9eaf..ed165d546 100644 --- a/internal/scrollcanvas/scroll_canvas_test.go +++ b/internal/scrollcanvas/scroll_canvas_test.go @@ -12,6 +12,7 @@ import ( ) func TestScrollCanvas(t *testing.T) { + t.Parallel() l := zaptest.NewLogger(t) m := matrix.NewConsoleMatrix(64, 32, io.Discard, l) c, err := NewScrollCanvas(m, l) diff --git a/internal/sportsmatrix/http.go b/internal/sportsmatrix/http.go index 0619decef..bd3dc0541 100644 --- a/internal/sportsmatrix/http.go +++ b/internal/sportsmatrix/http.go @@ -163,6 +163,7 @@ func (s *SportsMatrix) startHTTP() chan error { return errChan } +//nolint:contextcheck func (s *SportsMatrix) httpHandlers() []*board.HTTPHandler { return []*board.HTTPHandler{ { diff --git a/internal/sportsmatrix/sportsmatrix.go b/internal/sportsmatrix/sportsmatrix.go index 26ae6a15d..bade2ffd8 100644 --- a/internal/sportsmatrix/sportsmatrix.go +++ b/internal/sportsmatrix/sportsmatrix.go @@ -2,6 +2,7 @@ package sportsmatrix import ( "context" + "errors" "fmt" "net/http" _ "net/http/pprof" @@ -122,6 +123,7 @@ func (c *Config) Defaults() { } // New ... +// nolint:contextcheck func New(ctx context.Context, logger *zap.Logger, cfg *Config, canvases []board.Canvas, boards ...board.Board) (*SportsMatrix, error) { cfg.Defaults() @@ -329,7 +331,7 @@ func (s *SportsMatrix) startWebBoard(ctx context.Context) { default: } if err := s.launchWebBoard(ctx); err != nil { - if err == context.Canceled { + if errors.Is(err, context.Canceled) { s.log.Warn("web board context canceled, closing", zap.Error(err)) return } diff --git a/internal/sportsmatrix/sportsmatrix_test.go b/internal/sportsmatrix/sportsmatrix_test.go index d8faf1c62..56bafd82b 100644 --- a/internal/sportsmatrix/sportsmatrix_test.go +++ b/internal/sportsmatrix/sportsmatrix_test.go @@ -70,6 +70,7 @@ func (b *TestBoard) SetStateChangeNotifier(st board.StateChangeNotifier) { } func TestSportsMatrix(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(context.Background()) defer cancel() logger := zaptest.NewLogger(t, zaptest.Level(zapcore.ErrorLevel)) @@ -151,6 +152,7 @@ func TestSportsMatrix(t *testing.T) { } func TestScreenSwitch(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/script/lint b/script/lint index d1bceaf84..bd844b4e6 100755 --- a/script/lint +++ b/script/lint @@ -19,6 +19,7 @@ if [ "${IN_DOCKER}" = "no" ]; then -v "${ROOT}":/src${MOUNTOPTION} \ -w /src \ -e GOCACHE="/src/.cache" \ + -e GOFLAGS="-buildvcs=false" \ -e GOLANGCI_LINT_CACHE="/src/.cache" \ -e GO111MODULE=on \ -e CGO_ENABLED=1 \