From 904e60506df7fd08493ff6ec33af565107ef7b1a Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 1 Nov 2024 11:24:00 -0400 Subject: [PATCH] chore(lint): update soft lint directives; fix soft lint issues --- align.go | 6 +++--- color.go | 14 +++++++------- set.go | 18 +++++++++--------- table/util.go | 4 ++-- terminal.go | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/align.go b/align.go index 8e3cf4c2..03544d5b 100644 --- a/align.go +++ b/align.go @@ -29,8 +29,8 @@ func alignTextHorizontal(str string, pos Position, width int, style *ansi.Style) l = s + l case Center: // Note: remainder goes on the right. - left := shortAmount / 2 //nolint:gomnd - right := left + shortAmount%2 //nolint:gomnd + left := shortAmount / 2 //nolint:mnd + right := left + shortAmount%2 //nolint:mnd leftSpaces := strings.Repeat(" ", left) rightSpaces := strings.Repeat(" ", right) @@ -68,7 +68,7 @@ func alignTextVertical(str string, pos Position, height int, _ *ansi.Style) stri case Top: return str + strings.Repeat("\n", height-strHeight) case Center: - topPadding, bottomPadding := (height-strHeight)/2, (height-strHeight)/2 //nolint:gomnd + topPadding, bottomPadding := (height-strHeight)/2, (height-strHeight)/2 //nolint:mnd if strHeight+topPadding+bottomPadding > height { topPadding-- } else if strHeight+topPadding+bottomPadding < height { diff --git a/color.go b/color.go index 6b0e38f0..cacd2539 100644 --- a/color.go +++ b/color.go @@ -47,7 +47,7 @@ type NoColor struct{} // // Red: 0x0, Green: 0x0, Blue: 0x0, Alpha: 0xFFFF. func (n NoColor) RGBA() (r, g, b, a uint32) { - return 0x0, 0x0, 0x0, 0xFFFF //nolint:gomnd + return 0x0, 0x0, 0x0, 0xFFFF //nolint:mnd } // Color specifies a color by hex or ANSI256 value. For example: @@ -66,18 +66,18 @@ func Color(c any) color.Color { if h, err := colorful.Hex(c); err == nil { return h } else if i, err := strconv.Atoi(c); err == nil { - if i < 16 { //nolint:gomnd + if i < 16 { //nolint:mnd return ansi.BasicColor(i) //nolint:gosec - } else if i < 256 { //nolint:gomnd + } else if i < 256 { //nolint:mnd return ansi.ExtendedColor(i) //nolint:gosec } return ansi.TrueColor(i) //nolint:gosec } return noColor case int: - if c < 16 { + if c < 16 { //nolint:mnd return ansi.BasicColor(c) //nolint:gosec - } else if c < 256 { + } else if c < 256 { //nolint:mnd return ansi.ExtendedColor(c) //nolint:gosec } return ansi.TrueColor(c) //nolint:gosec @@ -101,7 +101,7 @@ func (c RGBColor) RGBA() (r, g, b, a uint32) { r |= uint32(c.R) << shift g |= uint32(c.G) << shift b |= uint32(c.B) << shift - a = 0xFFFF //nolint:gomnd + a = 0xFFFF return } @@ -177,5 +177,5 @@ func isDarkColor(c color.Color) bool { } _, _, l := col.Hsl() - return l < 0.5 + return l < 0.5 //nolint:mnd } diff --git a/set.go b/set.go index 1e294354..60937513 100644 --- a/set.go +++ b/set.go @@ -705,19 +705,19 @@ func whichSidesInt(i ...int) (top, right, bottom, left int, ok bool) { left = i[0] right = i[0] ok = true - case 2: //nolint:gomnd + case 2: //nolint:mnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: //nolint:gomnd + case 3: //nolint:mnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: //nolint:gomnd + case 4: //nolint:mnd top = i[0] right = i[1] bottom = i[2] @@ -738,19 +738,19 @@ func whichSidesBool(i ...bool) (top, right, bottom, left bool, ok bool) { left = i[0] right = i[0] ok = true - case 2: //nolint:gomnd + case 2: //nolint:mnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: //nolint:gomnd + case 3: //nolint:mnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: //nolint:gomnd + case 4: //nolint:mnd top = i[0] right = i[1] bottom = i[2] @@ -771,19 +771,19 @@ func whichSidesColor(i ...color.Color) (top, right, bottom, left color.Color, ok left = i[0] right = i[0] ok = true - case 2: //nolint:gomnd + case 2: //nolint:mnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: //nolint:gomnd + case 3: //nolint:mnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: //nolint:gomnd + case 4: //nolint:mnd top = i[0] right = i[1] bottom = i[2] diff --git a/table/util.go b/table/util.go index 4d152aa7..7d051129 100644 --- a/table/util.go +++ b/table/util.go @@ -45,8 +45,8 @@ func median(n []int) int { return 0 } if len(n)%2 == 0 { - h := len(n) / 2 //nolint:gomnd - return (n[h-1] + n[h]) / 2 //nolint:gomnd + h := len(n) / 2 //nolint:mnd + return (n[h-1] + n[h]) / 2 //nolint:mnd } return n[len(n)/2] } diff --git a/terminal.go b/terminal.go index 3ddf8a87..d5c663e6 100644 --- a/terminal.go +++ b/terminal.go @@ -22,7 +22,7 @@ import ( // // copied from x/term@v0.1.3. func queryBackgroundColor(in io.Reader, out io.Writer) (c color.Color, err error) { - // nolint: errcheck + //nolint: errcheck err = queryTerminal(in, out, defaultQueryTimeout, func(events []input.Event) bool { for _, e := range events { @@ -84,7 +84,7 @@ func queryTerminal( for { events, err := rd.ReadEvents() if err != nil { - return err + return fmt.Errorf("could not read events: %s", err) } if !filter(events) {