Skip to content

Commit 16760a9

Browse files
authored
feat: bump golangci-lint to v2.3.1 (#198)
1 parent 7de6bce commit 16760a9

File tree

10 files changed

+52
-32
lines changed

10 files changed

+52
-32
lines changed

.golangci.yaml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# https://golangci-lint.run/usage/linters/
2-
issues:
3-
exclude-use-default: false
1+
version: "2"
42
linters:
53
enable:
64
- asciicheck
@@ -12,36 +10,28 @@ linters:
1210
- dogsled
1311
- dupl
1412
- durationcheck
15-
- errcheck
13+
- err113
1614
- errname
1715
- errorlint
1816
- exhaustive
19-
- exportloopref
2017
- forbidigo
2118
- forcetypeassert
2219
- funlen
23-
- gci
2420
- gocognit
2521
- goconst
2622
- gocyclo
2723
- godot
28-
- goerr113
29-
- gofmt
3024
- goheader
31-
- goimports
32-
- gomnd
3325
- gomoddirectives
3426
- gomodguard
3527
- goprintffuncname
3628
- gosec
37-
- gosimple
38-
- govet
3929
- importas
40-
- ineffassign
4130
- ireturn
4231
- lll
4332
- makezero
4433
- misspell
34+
- mnd
4535
- nakedret
4636
- nestif
4737
- nilerr
@@ -56,16 +46,38 @@ linters:
5646
- rowserrcheck
5747
- sqlclosecheck
5848
- staticcheck
59-
- stylecheck
6049
- tagliatelle
61-
- tenv
6250
- thelper
6351
- tparallel
64-
- typecheck
6552
- unconvert
6653
- unparam
67-
- unused
6854
- varnamelen
6955
- wastedassign
7056
- whitespace
7157
- wrapcheck
58+
settings:
59+
depguard:
60+
rules:
61+
main:
62+
list-mode: lax
63+
allow:
64+
- github.com/stretchr/testify/assert
65+
- github.com/charmbracelet/lipgloss
66+
- github.com/muesli/reflow/wordwrap
67+
exclusions:
68+
generated: lax
69+
paths:
70+
- third_party$
71+
- builtin$
72+
- examples$
73+
formatters:
74+
enable:
75+
- gci
76+
- gofmt
77+
- goimports
78+
exclusions:
79+
generated: lax
80+
paths:
81+
- third_party$
82+
- builtin$
83+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fmt: ./bin/gci
7979
@./bin/gci write --skip-generated ./table/*.go
8080

8181
./bin/golangci-lint:
82-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.51.1
82+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v2.3.1
8383

8484
./bin/gci:
8585
GOBIN=$(shell pwd)/bin go install github.com/daixiang0/[email protected]

table/calc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package table
22

3+
// Keep compatibility with Go 1.21 by re-declaring min.
4+
//
5+
//nolint:predeclared
36
func min(x, y int) int {
47
if x < y {
58
return x
@@ -8,6 +11,9 @@ func min(x, y int) int {
811
return y
912
}
1013

14+
// Keep compatibility with Go 1.21 by re-declaring max.
15+
//
16+
//nolint:predeclared
1117
func max(x, y int) int {
1218
if x > y {
1319
return x

table/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func asInt(data interface{}) (int64, bool) {
2323
return val, true
2424

2525
case uint:
26+
// #nosec: G115
2627
return int64(val), true
2728

2829
case uint8:
@@ -35,6 +36,7 @@ func asInt(data interface{}) (int64, bool) {
3536
return int64(val), true
3637

3738
case uint64:
39+
// #nosec: G115
3840
return int64(val), true
3941

4042
case time.Duration:

table/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func TestSelectRowsProgramatically(t *testing.T) {
177177

178178
tests := map[string]struct {
179179
rows []Row
180-
selectedIds []int
180+
selectedIDs []int
181181
}{
182182
"no rows selected": {
183183
[]Row{
@@ -225,8 +225,8 @@ func TestSelectRowsProgramatically(t *testing.T) {
225225
model := baseModel.WithRows(test.rows)
226226
sel := model.SelectedRows()
227227

228-
assert.Equal(t, len(test.selectedIds), len(sel))
229-
for i, id := range test.selectedIds {
228+
assert.Equal(t, len(test.selectedIDs), len(sel))
229+
for i, id := range test.selectedIDs {
230230
assert.Equal(t, id, sel[i].Data[col], "expecting row %d to have same %s column value", i)
231231
}
232232

table/row.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,25 @@ func (r Row) WithStyle(style lipgloss.Style) Row {
5353
return r
5454
}
5555

56-
//nolint:nestif,cyclop // This has many ifs, but they're short
56+
//nolint:cyclop // This has many ifs, but they're short
5757
func (m Model) renderRowColumnData(row Row, column Column, rowStyle lipgloss.Style, borderStyle lipgloss.Style) string {
5858
cellStyle := rowStyle.Copy().Inherit(column.style).Inherit(m.baseStyle)
5959

6060
var str string
6161

62-
if column.key == columnKeySelect {
62+
switch column.key {
63+
case columnKeySelect:
6364
if row.selected {
6465
str = m.selectedText
6566
} else {
6667
str = m.unselectedText
6768
}
68-
} else if column.key == columnKeyOverflowRight {
69+
case columnKeyOverflowRight:
6970
cellStyle = cellStyle.Align(lipgloss.Right)
7071
str = ">"
71-
} else if column.key == columnKeyOverflowLeft {
72+
case columnKeyOverflowLeft:
7273
str = "<"
73-
} else {
74+
default:
7475
fmtString := "%v"
7576

7677
var data interface{}
@@ -137,7 +138,7 @@ func (m Model) renderBlankRow(last bool) string {
137138
// This is long and could use some refactoring in the future, but not quite sure
138139
// how to pick it apart yet.
139140
//
140-
//nolint:funlen, cyclop, gocognit
141+
//nolint:funlen, cyclop
141142
func (m Model) renderRowData(row Row, rowStyle lipgloss.Style, last bool) string {
142143
numColumns := len(m.columns)
143144

table/scrolling_fuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// This is long because of test cases
1616
//
17-
//nolint:funlen,gocognit,cyclop
17+
//nolint:funlen,cyclop
1818
func FuzzHorizontalScrollingStopEdgeCases(f *testing.F) {
1919
const (
2020
minNameWidth = 2

table/scrolling_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ func TestHorizontalScrollingWithFooterAndFrozenCols(t *testing.T) {
179179
assert.Equal(t, expectedTableOriginal, model.View())
180180
}
181181

182-
// This is long due to literal strings
183-
//
184-
//nolint:funlen
182+
// This is long due to literal strings.
185183
func TestHorizontalScrollStopsAtLastColumnBeingVisible(t *testing.T) {
186184
model := New([]Column{
187185
NewColumn("Name", "Name", 4),

table/strlimit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func limitStr(str string, maxLen int) string {
1818
}
1919

2020
if ansi.PrintableRuneWidth(str) > maxLen {
21+
// #nosec: G115
2122
return truncate.StringWithTail(str, uint(maxLen), "…")
2223
}
2324

table/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (m Model) View() string {
3030
if m.headerVisible {
3131
rowStrs = append(rowStrs, headers)
3232
} else if numRows > 0 || padding > 0 {
33-
//nolint: gomnd // This is just getting the first newlined substring
33+
//nolint: mnd // This is just getting the first newlined substring
3434
split := strings.SplitN(headers, "\n", 2)
3535
rowStrs = append(rowStrs, split[0])
3636
}

0 commit comments

Comments
 (0)