Skip to content

Commit

Permalink
chore(lint): add various nolint directives
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jul 24, 2023
1 parent df8b3fa commit 304b39a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
7 changes: 4 additions & 3 deletions align.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ func alignTextHorizontal(str string, pos Position, width int, style *termenv.Sty
shortAmount += max(0, width-(shortAmount+lineWidth)) // difference from the total width, if set

if shortAmount > 0 {
switch pos {
switch pos { //nolint:exhaustive
case Right:
s := strings.Repeat(" ", shortAmount)
if style != nil {
s = style.Styled(s)
}
l = s + l
case Center:
left := shortAmount / 2
right := left + shortAmount%2 // note that we put the remainder on the right
// Note: remainder goes on the right.
left := shortAmount / 2 //nolint:gomnd
right := left + shortAmount%2 //nolint:gomnd

leftSpaces := strings.Repeat(" ", left)
rightSpaces := strings.Repeat(" ", right)
Expand Down
4 changes: 2 additions & 2 deletions color.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (NoColor) color(*Renderer) termenv.Color {
//
// Deprecated.
func (n NoColor) RGBA() (r, g, b, a uint32) {
return 0x0, 0x0, 0x0, 0xFFFF
return 0x0, 0x0, 0x0, 0xFFFF //nolint:gomnd
}

// Color specifies a color by hex or ANSI value. For example:
Expand Down Expand Up @@ -123,7 +123,7 @@ type CompleteColor struct {

func (c CompleteColor) color(r *Renderer) termenv.Color {
p := r.ColorProfile()
switch p {
switch p { //nolint:exhaustive
case termenv.TrueColor:
return p.Color(c.TrueColor)
case termenv.ANSI256:
Expand Down
4 changes: 2 additions & 2 deletions join.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func JoinHorizontal(pos Position, strs ...string) string {

extraLines := make([]string, maxHeight-len(blocks[i]))

switch pos {
switch pos { //nolint:exhaustive
case Top:
blocks[i] = append(blocks[i], extraLines...)

Expand Down Expand Up @@ -139,7 +139,7 @@ func JoinVertical(pos Position, strs ...string) string {
for j, line := range block {
w := maxWidth - ansi.PrintableRuneWidth(line)

switch pos {
switch pos { //nolint:exhaustive
case Left:
b.WriteString(line)
b.WriteString(strings.Repeat(" ", w))
Expand Down
4 changes: 2 additions & 2 deletions position.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (r *Renderer) PlaceHorizontal(width int, pos Position, str string, opts ...
// Is this line shorter than the longest line?
short := max(0, contentWidth-ansi.PrintableRuneWidth(l))

switch pos {
switch pos { //nolint:exhaustive
case Left:
b.WriteString(l)
b.WriteString(ws.render(gap + short))
Expand Down Expand Up @@ -121,7 +121,7 @@ func (r *Renderer) PlaceVertical(height int, pos Position, str string, opts ...W
emptyLine := ws.render(width)
b := strings.Builder{}

switch pos {
switch pos { //nolint:exhaustive
case Top:
b.WriteString(str)
b.WriteRune('\n')
Expand Down
18 changes: 9 additions & 9 deletions set.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,19 @@ func whichSidesInt(i ...int) (top, right, bottom, left int, ok bool) {
left = i[0]
right = i[0]
ok = true
case 2:
case 2: //nolint:gomnd
top = i[0]
bottom = i[0]
left = i[1]
right = i[1]
ok = true
case 3:
case 3: //nolint:gomnd
top = i[0]
left = i[1]
right = i[1]
bottom = i[2]
ok = true
case 4:
case 4: //nolint:gomnd
top = i[0]
right = i[1]
bottom = i[2]
Expand All @@ -602,19 +602,19 @@ func whichSidesBool(i ...bool) (top, right, bottom, left bool, ok bool) {
left = i[0]
right = i[0]
ok = true
case 2:
case 2: //nolint:gomnd
top = i[0]
bottom = i[0]
left = i[1]
right = i[1]
ok = true
case 3:
case 3: //nolint:gomnd
top = i[0]
left = i[1]
right = i[1]
bottom = i[2]
ok = true
case 4:
case 4: //nolint:gomnd
top = i[0]
right = i[1]
bottom = i[2]
Expand All @@ -635,19 +635,19 @@ func whichSidesColor(i ...TerminalColor) (top, right, bottom, left TerminalColor
left = i[0]
right = i[0]
ok = true
case 2:
case 2: //nolint:gomnd
top = i[0]
bottom = i[0]
left = i[1]
right = i[1]
ok = true
case 3:
case 3: //nolint:gomnd
top = i[0]
left = i[1]
right = i[1]
bottom = i[2]
ok = true
case 4:
case 4: //nolint:gomnd
top = i[0]
right = i[1]
bottom = i[2]
Expand Down
2 changes: 1 addition & 1 deletion style.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s Style) Inherit(i Style) Style {
s.init()

for k, v := range i.rules {
switch k {
switch k { //nolint:exhaustive
case marginTopKey, marginRightKey, marginBottomKey, marginLeftKey:
// Margins are not inherited
continue
Expand Down

0 comments on commit 304b39a

Please sign in to comment.