Skip to content

Commit 5369c1e

Browse files
committed
build: Fix linter issues
Signed-off-by: Paulo Gomes <[email protected]>
1 parent f0786fc commit 5369c1e

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

fixtures.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,7 @@ type Fixture struct {
232232
}
233233

234234
func (f *Fixture) Is(tag string) bool {
235-
for _, t := range f.Tags {
236-
if t == tag {
237-
return true
238-
}
239-
}
240-
241-
return false
235+
return slices.Contains(f.Tags, tag)
242236
}
243237

244238
func (f *Fixture) Packfile() billy.File {
@@ -316,7 +310,8 @@ func (f *Fixture) Clone() *Fixture {
316310

317311
// EnsureIsBare overrides the config file with one where bare is true.
318312
func EnsureIsBare(fs billy.Filesystem) error {
319-
if _, err := fs.Stat("config"); err != nil {
313+
_, err := fs.Stat("config")
314+
if err != nil {
320315
return fmt.Errorf("not .git folder: %w", err)
321316
}
322317

@@ -370,6 +365,7 @@ type Fixtures []*Fixture
370365
// Run calls test within a t.Run for each fixture in g.
371366
func (g Fixtures) Run(t *testing.T, test func(*testing.T, *Fixture)) {
372367
t.Helper()
368+
373369
for _, f := range g {
374370
name := fmt.Sprintf("fixture run (%q, %q)", f.URL, f.Tags)
375371
t.Run(name, func(t *testing.T) {

fixtures_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ func TestRevFiles(t *testing.T) {
7171

7272
func TestAll(t *testing.T) {
7373
t.Parallel()
74+
7475
fs := fixtures.All()
7576

7677
assert.Len(t, fs, 39)
7778
}
7879

7980
func TestByTag(t *testing.T) {
8081
t.Parallel()
82+
8183
tests := []struct {
8284
tag string
8385
len int

internal/tgz/tgz.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func filemode(mode int64) (fs.FileMode, error) {
6262
if mode < 0 {
6363
return 0, ErrCannotBeNegative
6464
}
65+
6566
if mode > math.MaxUint32 {
6667
return 0, ErrCannotBeGreaterThanMaxUInt32
6768
}
@@ -81,10 +82,12 @@ func unTar(fs billy.Filesystem, src *tar.Reader) error {
8182
}
8283

8384
dst := header.Name
85+
8486
mode, err := filemode(header.Mode)
8587
if err != nil {
8688
return err
8789
}
90+
8891
switch header.Typeflag {
8992
case tar.TypeDir:
9093
err := fs.MkdirAll(dst, mode)
@@ -110,6 +113,7 @@ func makeFile(fs billy.Filesystem, path string, mode os.FileMode, contents io.Re
110113
if err != nil {
111114
return err
112115
}
116+
113117
defer func() {
114118
errClose := w.Close()
115119
if err == nil {
@@ -123,7 +127,8 @@ func makeFile(fs billy.Filesystem, path string, mode os.FileMode, contents io.Re
123127
}
124128

125129
if fs, ok := fs.(billy.Change); ok {
126-
if err = fs.Chmod(path, mode); err != nil {
130+
err = fs.Chmod(path, mode)
131+
if err != nil {
127132
return err
128133
}
129134
}

internal/tgz/tgz_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestExtractError(t *testing.T) {
4545
require.NoError(t, err)
4646

4747
source := osfs.New(d + "/fixtures")
48+
4849
f, err := source.Open(tc.tgz)
4950
if tc.notFound {
5051
require.ErrorIs(t, err, os.ErrNotExist)

osfixture.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import (
99
)
1010

1111
type OSFixture struct {
12-
dir string
1312
*Fixture
13+
14+
dir string
1415
}
1516

1617
// NewOSFixture converts a Fixture which is based on embedfs, into
1718
// an OS based fixture.
1819
func NewOSFixture(f *Fixture, dir string) *OSFixture {
1920
return &OSFixture{
20-
dir: dir,
2121
Fixture: f,
22+
dir: dir,
2223
}
2324
}
2425

@@ -67,6 +68,7 @@ func embedToOsfs(dir string, f billy.File) billy.File {
6768
defer f.Close()
6869

6970
fs := osfs.New(dir)
71+
7072
out, err := fs.TempFile("", "embed")
7173
if err != nil {
7274
panic(err)

0 commit comments

Comments
 (0)