running golangci-lint

Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
This commit is contained in:
Navid Yaghoobi 2024-10-13 22:28:43 +11:00
parent 12e9f953a3
commit 091fcae5c5

12
plot.go
View File

@ -280,6 +280,7 @@ func (plot *Plot) drawAxesToScreen(screen tcell.Screen) {
} }
} }
//nolint:funlen,cyclop
func (plot *Plot) drawXAxisLabelsToScreen( func (plot *Plot) drawXAxisLabelsToScreen(
screen tcell.Screen, plotYAxisLabelsWidth int, x int, y int, width int, height int, screen tcell.Screen, plotYAxisLabelsWidth int, x int, y int, width int, height int,
) { ) {
@ -297,8 +298,8 @@ func (plot *Plot) drawXAxisLabelsToScreen(
// determine the width needed for the largest label // determine the width needed for the largest label
maxXAxisLabelWidth := 0 maxXAxisLabelWidth := 0
for _, d := range plot.data {
for _, d := range plot.data {
for i := range d { for i := range d {
label := plot.xAxisLabelFunc(i) label := plot.xAxisLabelFunc(i)
labelMap[i] = label labelMap[i] = label
@ -313,11 +314,12 @@ func (plot *Plot) drawXAxisLabelsToScreen(
for i, label := range labelMap { for i, label := range labelMap {
expectedLabelWidth := len(label) expectedLabelWidth := len(label)
if i == 0 { if i == 0 {
expectedLabelWidth += plotXAxisLabelsGap / 2 expectedLabelWidth += plotXAxisLabelsGap / 2 //nolint:gomnd
} else { } else {
expectedLabelWidth += plotXAxisLabelsGap expectedLabelWidth += plotXAxisLabelsGap
} }
currentLabelStart := i - int(math.Round(float64(expectedLabelWidth)/2))
currentLabelStart := i - int(math.Round(float64(expectedLabelWidth)/2)) //nolint:gomnd
labelStartMap[i] = currentLabelStart labelStartMap[i] = currentLabelStart
} }
@ -337,9 +339,9 @@ func (plot *Plot) drawXAxisLabelsToScreen(
labelWithGap := rawLabel labelWithGap := rawLabel
if i == 0 { if i == 0 {
labelWithGap += strings.Repeat(gapRune, plotXAxisLabelsGap/2) labelWithGap += strings.Repeat(gapRune, plotXAxisLabelsGap/2) //nolint:gomnd
} else { } else {
labelWithGap = strings.Repeat(gapRune, plotXAxisLabelsGap/2) + labelWithGap + strings.Repeat(gapRune, plotXAxisLabelsGap/2) labelWithGap = strings.Repeat(gapRune, plotXAxisLabelsGap/2) + labelWithGap + strings.Repeat(gapRune, plotXAxisLabelsGap/2) //nolint:lll,gomnd
} }
expectedLabelWidth := len(labelWithGap) expectedLabelWidth := len(labelWithGap)