From 36e3d86da46b89abf3f57e5b8f373493f2b933af Mon Sep 17 00:00:00 2001 From: Navid Yaghoobi Date: Tue, 5 Mar 2024 21:56:13 +1100 Subject: [PATCH] golangci-lint update 1.56.2 Signed-off-by: Navid Yaghoobi --- .golangci.yml | 1 + Makefile | 2 +- barchart.go | 6 +++--- dialog.go | 2 ++ gauge_am.go | 2 +- gauge_pm.go | 2 +- gauge_um.go | 2 +- plot.go | 8 +++----- sparkline.go | 1 + 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 88c351e..0d6e93f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,6 +9,7 @@ linters: disable: - varnamelen - exhaustruct + - depguard # deprecated - rowserrcheck - wastedassign diff --git a/Makefile b/Makefile index e26f6bc..034922e 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ install.tools: .install.pre-commit .install.codespell .install.golangci-lint .in .PHONY: .install.golangci-lint .install.golangci-lint: - VERSION=1.51.1 ./hack/install_golangci.sh + VERSION=1.56.2 ./hack/install_golangci.sh #================================================= # Testing (units, functionality, ...) targets diff --git a/barchart.go b/barchart.go index 79785e3..6715f2d 100644 --- a/barchart.go +++ b/barchart.go @@ -1,7 +1,7 @@ package tvxwidgets import ( - "fmt" + "strconv" "github.com/gdamore/tcell/v2" "github.com/rivo/tview" @@ -76,7 +76,7 @@ func (c *BarChart) Draw(screen tcell.Screen) { //nolint:funlen,cyclop } // set max value if not set c.initMaxValue() - maxValueSr := fmt.Sprintf("%d", c.maxVal) + maxValueSr := strconv.Itoa(c.maxVal) maxValLenght := len(maxValueSr) + 1 if maxValLenght < barChartYAxisLabelWidth { @@ -136,7 +136,7 @@ func (c *BarChart) Draw(screen tcell.Screen) { //nolint:funlen,cyclop } } // bar value - vSt := fmt.Sprintf("%d", item.value) + vSt := strconv.Itoa(item.value) vRune := []rune(vSt) for i := 0; i < len(vRune); i++ { diff --git a/dialog.go b/dialog.go index e5d1d66..173061a 100644 --- a/dialog.go +++ b/dialog.go @@ -133,6 +133,7 @@ func (d *MessageDialog) InputHandler() func(event *tcell.EventKey, setFocus func return } } + if formHandler := d.form.InputHandler(); formHandler != nil { formHandler(event, setFocus) @@ -148,6 +149,7 @@ func (d *MessageDialog) MouseHandler() func(action tview.MouseAction, event *tce consumed, capture = d.form.MouseHandler()(action, event, setFocus) if !consumed && action == tview.MouseLeftClick && d.InRect(event.Position()) { setFocus(d) + consumed = true } diff --git a/gauge_am.go b/gauge_am.go index 75911c0..3218b98 100644 --- a/gauge_am.go +++ b/gauge_am.go @@ -40,7 +40,7 @@ func (g *ActivityModeGauge) Draw(screen tcell.Screen) { } // Focus is called when this primitive receives focus. -func (g *ActivityModeGauge) Focus(delegate func(p tview.Primitive)) { +func (g *ActivityModeGauge) Focus(delegate func(p tview.Primitive)) { //nolint:revive } // HasFocus returns whether or not this primitive has focus. diff --git a/gauge_pm.go b/gauge_pm.go index 3115172..02bfb96 100644 --- a/gauge_pm.go +++ b/gauge_pm.go @@ -70,7 +70,7 @@ func (g *PercentageModeGauge) Draw(screen tcell.Screen) { } // Focus is called when this primitive receives focus. -func (g *PercentageModeGauge) Focus(delegate func(p tview.Primitive)) { +func (g *PercentageModeGauge) Focus(delegate func(p tview.Primitive)) { //nolint:revive } // HasFocus returns whether or not this primitive has focus. diff --git a/gauge_um.go b/gauge_um.go index bee5a8f..f4ea255 100644 --- a/gauge_um.go +++ b/gauge_um.go @@ -59,7 +59,7 @@ func (g *UtilModeGauge) SetLabelColor(color tcell.Color) { } // Focus is called when this primitive receives focus. -func (g *UtilModeGauge) Focus(delegate func(p tview.Primitive)) { +func (g *UtilModeGauge) Focus(delegate func(p tview.Primitive)) { //nolint:revive } // HasFocus returns whether or not this primitive has focus. diff --git a/plot.go b/plot.go index ddc693d..d57d0ae 100644 --- a/plot.go +++ b/plot.go @@ -3,6 +3,7 @@ package tvxwidgets import ( "fmt" "image" + "strconv" "sync" "github.com/gdamore/tcell/v2" @@ -226,10 +227,7 @@ func (plot *Plot) drawXAxisLabelToScreen( for labelX := x + plotYAxisLabelsWidth + (plotXAxisLabelsGap)*plotHorizontalScale + 1; labelX < x+width-1; { - label := fmt.Sprintf( - "%d", - (labelX-(x+plotYAxisLabelsWidth)-1)/(plotHorizontalScale)+1, - ) + label := strconv.Itoa((labelX-(x+plotYAxisLabelsWidth)-1)/(plotHorizontalScale) + 1) tview.Print(screen, label, labelX, y+height-plotXAxisLabelsHeight, width, tview.AlignLeft, plot.axesLabelColor) @@ -251,7 +249,7 @@ func (plot *Plot) drawYAxisLabelToScreen(screen tcell.Screen, plotYAxisLabelsWid } } -//nolint:gocognit,cyclop +//nolint:cyclop func (plot *Plot) drawDotMarkerToScreen(screen tcell.Screen) { x, y, width, height := plot.getChartAreaRect() chartData := plot.getData() diff --git a/sparkline.go b/sparkline.go index 231739b..d999bb2 100644 --- a/sparkline.go +++ b/sparkline.go @@ -35,6 +35,7 @@ func (sl *Sparkline) Draw(screen tcell.Screen) { // print label if sl.dataTitle != "" { tview.Print(screen, sl.dataTitle, x, y, width, tview.AlignLeft, sl.dataTitlecolor) + barHeight-- }