From 9622000f0976d1ce67671c5363ffcde926968cbd Mon Sep 17 00:00:00 2001 From: Zac Date: Wed, 13 Nov 2024 20:59:27 +0000 Subject: [PATCH] More linting --- .golangci.yml | 1 + backend/timer.go | 4 ++-- common/arena.go | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 222f810..c5b4d0c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,6 +11,7 @@ linters: - inamedparam - ireturn - mnd + - musttag - nlreturn - nonamedreturns - paralleltest diff --git a/backend/timer.go b/backend/timer.go index c1ea1b2..4cf1ee2 100644 --- a/backend/timer.go +++ b/backend/timer.go @@ -40,7 +40,7 @@ func (t *Timer) Pause() *Timer { return t } -// Reset starts the timer from zero. +// Reset sets the timer to zero. func (t *Timer) Reset() *Timer { t.Time = 0 return t @@ -52,7 +52,7 @@ func (t *Timer) Set(d time.Duration) *Timer { return t } -// Duration returns the current time in time.Duration format. +// Duration returns the current time. func (t *Timer) Duration() time.Duration { return t.Time } diff --git a/common/arena.go b/common/arena.go index e325ad0..dfe3a43 100644 --- a/common/arena.go +++ b/common/arena.go @@ -748,19 +748,18 @@ func (a newFromCombineRowAnimation) String() string { return fmt.Sprint("new-from-combine at ", a.dest) } -// generateAnimations generates animation data a row of tiles. +// generateAnimations generates animation data for a row of tiles. func generateRowAnimations(before, after [numTiles]grid.Tile, dir grid.Direction) []rowAnimation { var rowAnimations []rowAnimation - // Index "before" tiles by UUID : position in row + // Build a map of each tile's "before" position, indexed by their UUID beforeUUIDs := make(map[uuid.UUID]int, numTiles) for x := range before { beforeUUIDs[before[x].UUID] = x } - // Evaluate "after" tiles for x := range after { - // Tiles with the same UUIDs have moved + // Like UUIDs indicates that a tile has moved beforePos, ok := beforeUUIDs[after[x].UUID] if ok && !(beforePos == x) { rowAnimations = append(rowAnimations, moveRowAnimation{ @@ -769,7 +768,7 @@ func generateRowAnimations(before, after [numTiles]grid.Tile, dir grid.Direction }) } - // Tiles with the Cmb set are from combinations + // Tiles with the Cmb flag set are from combinations if after[x].Cmb { // Newly formed tile from combination rowAnimations = append(rowAnimations, newFromCombineRowAnimation{