Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
robbydyer committed Aug 16, 2024
1 parent f41f6dc commit 46dafdd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions internal/board/image/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func filenameCompare(a string, b string) bool {
return false
}

max := len(aPaths)
if len(bPaths) > max {
max = len(bPaths)
maxPath := len(aPaths)
if len(bPaths) > maxPath {
maxPath = len(bPaths)
}

for x := 0; x < max; x++ {
for x := 0; x < maxPath; x++ {
if len(aPaths) < x+1 || len(bPaths) < x+1 {
return true
}
Expand Down
10 changes: 5 additions & 5 deletions internal/board/racing/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,23 @@ func (s *RacingBoard) renderEvent(ctx context.Context, bounds image.Rectangle, e
if err != nil {
return nil, err
}
max := canvasBounds.Dx() / 2
maxX := canvasBounds.Dx() / 2

for _, length := range lengths {
if length > max {
max = length
if length > maxX {
maxX = length
}
}

s.log.Debug("max racing schedule text length",
zap.Int("max", max),
zap.Int("max", maxX),
zap.Int("half bounds", canvasBounds.Dy()/2),
)

scheduleBounds := image.Rect(
canvasBounds.Max.X/2,
canvasBounds.Min.Y,
(canvasBounds.Max.X/2)+max,
(canvasBounds.Max.X/2)+maxX,
canvasBounds.Max.Y,
)

Expand Down
8 changes: 4 additions & 4 deletions internal/board/sport/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ func (s *SportBoard) calculateTeamInfoWidth(canvas draw.Image, writer *rgbrender
return defaultTeamInfoArea, err
}

max := 0
maxLen := 0
for _, l := range lengths {
if l > max {
max = l
if l > maxLen {
maxLen = l
}
}

return max, nil
return maxLen, nil
}

func (s *SportBoard) writeBoxColor() color.Color {
Expand Down
6 changes: 3 additions & 3 deletions internal/board/stat/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ func maxNameLength(canvas image.Rectangle) int {
return canvas.Dx() / 8
}

func maxedStr(str string, max int) string {
if max <= 0 || len(str) <= max {
func maxedStr(str string, maxLen int) string {
if maxLen <= 0 || len(str) <= maxLen {
return str
}

start := float64(max) / 2.0
start := float64(maxLen) / 2.0
i := int(start)
j := int(start) - 1
if math.Trunc(start) != start {
Expand Down
10 changes: 5 additions & 5 deletions internal/rgbrender/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ func (l *LayerDrawer) ClearLayers() {

func (l *LayerDrawer) setForegroundPriority() {
hasForeground := false
max := BackgroundPriority
maxP := BackgroundPriority
for i := range l.layerPriorities {
if i > max {
max = i
if i > maxP {
maxP = i
}
if i == ForegroundPriority {
hasForeground = true
delete(l.layerPriorities, i)
}
}

l.maxLayer = max
l.maxLayer = maxP

if !hasForeground {
return
}

l.maxLayer = max + 1
l.maxLayer = maxP + 1

l.layerPriorities[l.maxLayer] = struct{}{}

Expand Down
4 changes: 2 additions & 2 deletions internal/rgbrender/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ func (c *ColorChar) validate() error {

// BreakText breaks text into lines based on a max pixel width
func (t *TextWriter) BreakText(canvas draw.Image, maxPixWidth int, text string) ([]string, error) {
max, err := t.MaxChars(canvas, maxPixWidth)
maxChar, err := t.MaxChars(canvas, maxPixWidth)
if err != nil {
return []string{}, err
}

return breakText(max, text), nil
return breakText(maxChar, text), nil
}

func breakText(maxLineLen int, text string) []string {
Expand Down
4 changes: 2 additions & 2 deletions internal/scrollcanvas/scroll_canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ func (c *ScrollCanvas) SetScrollSpeed(d time.Duration) {
return
}

max := 2
maxTry := 2
try := 0
for {
if try >= max {
if try >= maxTry {
break
}
try++
Expand Down

0 comments on commit 46dafdd

Please sign in to comment.