Skip to content

Commit 5b4625f

Browse files
authored
Merge pull request #165 from pjbgf/bump
build: Bump golangci-lint to v2.6.0
2 parents d09f64a + 466dfbd commit 5b4625f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+270
-170
lines changed

.github/dependabot.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.golangci.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ linters:
2727
- goprintffuncname
2828
- gosmopolitan
2929
- govet
30+
- forcetypeassert
3031
- grouper
3132
- importas
3233
- ineffassign
@@ -47,6 +48,8 @@ linters:
4748
- tagalign
4849
- tagliatelle
4950
- testableexamples
51+
- thelper
52+
- tparallel
5053
- unconvert
5154
- unused
5255
- usestdlibvars
@@ -60,16 +63,18 @@ linters:
6063
- common-false-positives
6164
- legacy
6265
- std-error-handling
63-
paths:
64-
- third_party$
65-
- builtin$
66-
- examples$
66+
67+
settings:
68+
revive:
69+
rules:
70+
- name: var-naming
71+
disabled: true
72+
6773
formatters:
6874
enable:
75+
- gci
76+
- gofmt
77+
- gofumpt
6978
- goimports
7079
exclusions:
7180
generated: lax
72-
paths:
73-
- third_party$
74-
- builtin$
75-
- examples$

.renovaterc.json5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["github>go-git/.github"]
4+
}

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ WASIRUN_WRAPPER := $(CURDIR)/scripts/wasirun-wrapper
77
COVERAGE_REPORT := coverage.out
88
COVERAGE_MODE := count
99

10-
GOLANGCI_VERSION ?= v2.1.6
10+
# renovate: datasource=github-tags depName=golangci/golangci-lint
11+
GOLANGCI_VERSION ?= v2.6.0
1112
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools)
1213

1314
GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
@@ -50,3 +51,6 @@ ifneq ($(shell git status --porcelain --untracked-files=no),)
5051
@git --no-pager diff
5152
@exit 1
5253
endif
54+
55+
lint-autofix: $(GOLANGCI) # Auto fix supported lint issues.
56+
$(GOLANGCI) run --fix

embedfs/embed_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func TestOpen(t *testing.T) {
4444

4545
for _, tc := range tests {
4646
t.Run(tc.name, func(t *testing.T) {
47+
t.Parallel()
48+
4749
fs := New(&testdataDir)
4850

4951
var got []byte
@@ -115,6 +117,7 @@ func TestOpenFileFlags(t *testing.T) {
115117

116118
for _, tc := range tests {
117119
t.Run(tc.name, func(t *testing.T) {
120+
t.Parallel()
118121
fs := New(&testdataDir)
119122

120123
_, err := fs.OpenFile(tc.file, tc.flag, 0o700)
@@ -157,6 +160,7 @@ func TestStat(t *testing.T) {
157160

158161
for _, tc := range tests {
159162
t.Run(tc.name, func(t *testing.T) {
163+
t.Parallel()
160164
fs := New(&testdataDir)
161165

162166
fi, err := fs.Stat(tc.name)
@@ -213,6 +217,7 @@ func TestReadDir(t *testing.T) {
213217

214218
for _, tc := range tests {
215219
t.Run(tc.name, func(t *testing.T) {
220+
t.Parallel()
216221
fs := New(tc.fs)
217222

218223
fis, err := fs.ReadDir(tc.path)
@@ -296,6 +301,7 @@ func TestFileSeek(t *testing.T) {
296301

297302
for i, tc := range tests {
298303
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
304+
//nolint:tparallel
299305
_, err = f.Seek(tc.seekOff, tc.seekWhence)
300306
require.NoError(t, err)
301307

@@ -309,6 +315,8 @@ func TestFileSeek(t *testing.T) {
309315
}
310316

311317
func TestJoin(t *testing.T) {
318+
t.Parallel()
319+
312320
tests := []struct {
313321
name string
314322
path []string
@@ -338,6 +346,7 @@ func TestJoin(t *testing.T) {
338346

339347
for _, tc := range tests {
340348
t.Run(tc.name, func(t *testing.T) {
349+
t.Parallel()
341350
fs := New(&empty)
342351

343352
got := fs.Join(tc.path...)

helper/chroot/chroot.go

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package chroot
22

33
import (
4+
"errors"
45
"io/fs"
56
"os"
67
"path/filepath"
@@ -126,7 +127,12 @@ func (fs *ChrootHelper) TempFile(dir, prefix string) (billy.File, error) {
126127
return nil, err
127128
}
128129

129-
f, err := fs.underlying.(billy.TempFile).TempFile(fullpath, prefix)
130+
tf, ok := fs.underlying.(billy.TempFile)
131+
if !ok {
132+
return nil, errors.New("underlying fs does not implement billy.TempFile")
133+
}
134+
135+
f, err := tf.TempFile(fullpath, prefix)
130136
if err != nil {
131137
return nil, err
132138
}
@@ -140,7 +146,11 @@ func (fs *ChrootHelper) ReadDir(path string) ([]fs.DirEntry, error) {
140146
return nil, err
141147
}
142148

143-
return fs.underlying.(billy.Dir).ReadDir(fullpath)
149+
d, ok := fs.underlying.(billy.Dir)
150+
if !ok {
151+
return nil, errors.New("underlying fs does not implement billy.Dir")
152+
}
153+
return d.ReadDir(fullpath)
144154
}
145155

146156
func (fs *ChrootHelper) MkdirAll(filename string, perm fs.FileMode) error {
@@ -149,7 +159,11 @@ func (fs *ChrootHelper) MkdirAll(filename string, perm fs.FileMode) error {
149159
return err
150160
}
151161

152-
return fs.underlying.(billy.Dir).MkdirAll(fullpath, perm)
162+
d, ok := fs.underlying.(billy.Dir)
163+
if !ok {
164+
return errors.New("underlying fs does not implement billy.Dir")
165+
}
166+
return d.MkdirAll(fullpath, perm)
153167
}
154168

155169
func (fs *ChrootHelper) Lstat(filename string) (os.FileInfo, error) {
@@ -158,7 +172,11 @@ func (fs *ChrootHelper) Lstat(filename string) (os.FileInfo, error) {
158172
return nil, err
159173
}
160174

161-
return fs.underlying.(billy.Symlink).Lstat(fullpath)
175+
sl, ok := fs.underlying.(billy.Symlink)
176+
if !ok {
177+
return nil, errors.New("underlying fs does not implement billy.Symlink")
178+
}
179+
return sl.Lstat(fullpath)
162180
}
163181

164182
func (fs *ChrootHelper) Symlink(target, link string) error {
@@ -175,7 +193,11 @@ func (fs *ChrootHelper) Symlink(target, link string) error {
175193
return err
176194
}
177195

178-
return fs.underlying.(billy.Symlink).Symlink(target, link)
196+
sl, ok := fs.underlying.(billy.Symlink)
197+
if !ok {
198+
return errors.New("underlying fs does not implement billy.Symlink")
199+
}
200+
return sl.Symlink(target, link)
179201
}
180202

181203
func (fs *ChrootHelper) Readlink(link string) (string, error) {
@@ -184,7 +206,12 @@ func (fs *ChrootHelper) Readlink(link string) (string, error) {
184206
return "", err
185207
}
186208

187-
target, err := fs.underlying.(billy.Symlink).Readlink(fullpath)
209+
sl, ok := fs.underlying.(billy.Symlink)
210+
if !ok {
211+
return "", errors.New("underlying fs does not implement billy.Symlink")
212+
}
213+
214+
target, err := sl.Readlink(fullpath)
188215
if err != nil {
189216
return "", err
190217
}

helper/chroot/chroot_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ func TestOpenFile(t *testing.T) {
8484
m := &test.BasicMock{}
8585

8686
fs := New(m, "/foo")
87-
f, err := fs.OpenFile("bar/qux", 42, 0777)
87+
f, err := fs.OpenFile("bar/qux", 42, 0o777)
8888
require.NoError(t, err)
8989
assert.Equal(t, f.Name(), filepath.Join("bar", "qux"))
9090

9191
assert.Len(t, m.OpenFileArgs, 1)
92-
assert.Equal(t, m.OpenFileArgs[0], [3]interface{}{"/foo/bar/qux", 42, os.FileMode(0777)})
92+
assert.Equal(t, m.OpenFileArgs[0], [3]interface{}{"/foo/bar/qux", 42, os.FileMode(0o777)})
9393
}
9494

9595
func TestOpenFileErrCrossedBoundary(t *testing.T) {
9696
m := &test.BasicMock{}
9797

9898
fs := New(m, "/foo")
99-
_, err := fs.OpenFile("../foo", 42, 0777)
99+
_, err := fs.OpenFile("../foo", 42, 0o777)
100100
assert.ErrorIs(t, err, billy.ErrCrossedBoundary)
101101
}
102102

@@ -218,18 +218,18 @@ func TestMkDirAll(t *testing.T) {
218218
m := &test.DirMock{}
219219

220220
fs := New(m, "/foo")
221-
err := fs.MkdirAll("bar", 0777)
221+
err := fs.MkdirAll("bar", 0o777)
222222
require.NoError(t, err)
223223

224224
assert.Len(t, m.MkdirAllArgs, 1)
225-
assert.Equal(t, m.MkdirAllArgs[0], [2]interface{}{"/foo/bar", os.FileMode(0777)})
225+
assert.Equal(t, m.MkdirAllArgs[0], [2]interface{}{"/foo/bar", os.FileMode(0o777)})
226226
}
227227

228228
func TestMkdirAllErrCrossedBoundary(t *testing.T) {
229229
m := &test.DirMock{}
230230

231231
fs := New(m, "/foo")
232-
err := fs.MkdirAll("../foo", 0777)
232+
err := fs.MkdirAll("../foo", 0o777)
233233
assert.ErrorIs(t, err, billy.ErrCrossedBoundary)
234234
}
235235

@@ -353,6 +353,7 @@ func TestCapabilities(t *testing.T) {
353353
}
354354

355355
func testCapabilities(t *testing.T, basic billy.Basic) {
356+
t.Helper()
356357
baseCapabilities := billy.Capabilities(basic)
357358

358359
fs := New(basic, "/foo")

helper/iofs/iofs.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ type adapterFs struct {
2121
}
2222

2323
// Type assertion that adapterFS implements the following interfaces:
24-
var _ fs.FS = (*adapterFs)(nil)
25-
var _ fs.ReadDirFS = (*adapterFs)(nil)
26-
var _ fs.StatFS = (*adapterFs)(nil)
27-
var _ fs.ReadFileFS = (*adapterFs)(nil)
24+
var (
25+
_ fs.FS = (*adapterFs)(nil)
26+
_ fs.ReadDirFS = (*adapterFs)(nil)
27+
_ fs.StatFS = (*adapterFs)(nil)
28+
_ fs.ReadFileFS = (*adapterFs)(nil)
29+
)
2830

2931
// TODO: implement fs.GlobFS, which will be a fair bit more code.
3032

helper/iofs/iofs_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
billyfs "github.com/go-git/go-billy/v6"
1313
"github.com/go-git/go-billy/v6/memfs"
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
type errorList interface {
@@ -30,7 +31,7 @@ func TestWithFSTest(t *testing.T) {
3031
}
3132
createdFiles := make([]string, 0, len(files))
3233
for filename, contents := range files {
33-
makeFile(memfs, t, filename, contents)
34+
makeFile(t, memfs, filename, contents)
3435
createdFiles = append(createdFiles, filename)
3536
}
3637

@@ -47,10 +48,11 @@ func TestWithFSTest(t *testing.T) {
4748
func TestDeletes(t *testing.T) {
4849
t.Parallel()
4950
memfs := memfs.New()
50-
iofs := New(memfs).(fs.ReadFileFS)
51+
iofs, ok := New(memfs).(fs.ReadFileFS)
52+
require.True(t, ok)
5153

52-
makeFile(memfs, t, "foo.txt", "hello, world")
53-
makeFile(memfs, t, "deleted", "nothing to see")
54+
makeFile(t, memfs, "foo.txt", "hello, world")
55+
makeFile(t, memfs, "deleted", "nothing to see")
5456

5557
if _, err := iofs.ReadFile("nonexistent"); err == nil {
5658
t.Errorf("expected error for nonexistent file")
@@ -73,7 +75,7 @@ func TestDeletes(t *testing.T) {
7375
}
7476
}
7577

76-
func makeFile(fs billyfs.Basic, t *testing.T, filename string, contents string) {
78+
func makeFile(t *testing.T, fs billyfs.Basic, filename string, contents string) {
7779
t.Helper()
7880
file, err := fs.Create(filename)
7981
if err != nil {

0 commit comments

Comments
 (0)