Skip to content

Commit 4e8daac

Browse files
authoredJun 14, 2024··
Merge pull request #320 from numtide/golangci-lint
chore: do a golangci-lint pass
2 parents 6b59125 + 6d6a71a commit 4e8daac

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed
 

‎cli/format_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestOnUnmatched(t *testing.T) {
4949
// - "haskell/treefmt.toml"
5050
}
5151

52-
out, err := cmd(t, "-C", tempDir, "--allow-missing-formatter", "--on-unmatched", "fatal")
52+
_, err = cmd(t, "-C", tempDir, "--allow-missing-formatter", "--on-unmatched", "fatal")
5353
as.ErrorContains(err, fmt.Sprintf("no formatter for path: %s", paths[0]))
5454

5555
checkOutput := func(level string, output []byte) {
@@ -58,6 +58,8 @@ func TestOnUnmatched(t *testing.T) {
5858
}
5959
}
6060

61+
var out []byte
62+
6163
// default is warn
6264
out, err = cmd(t, "-C", tempDir, "--allow-missing-formatter", "-c")
6365
as.NoError(err)
@@ -271,8 +273,13 @@ func TestCache(t *testing.T) {
271273
},
272274
}
273275

276+
var (
277+
out []byte
278+
err error
279+
)
280+
274281
test.WriteConfig(t, configPath, cfg)
275-
out, err := cmd(t, "--config-file", configPath, "--tree-root", tempDir)
282+
_, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir)
276283
as.NoError(err)
277284
assertStats(t, as, 31, 31, 31, 0)
278285

@@ -281,7 +288,7 @@ func TestCache(t *testing.T) {
281288
assertFormatted(t, as, out, 0)
282289

283290
// clear cache
284-
out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c")
291+
_, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c")
285292
as.NoError(err)
286293
assertStats(t, as, 31, 31, 31, 0)
287294

@@ -290,7 +297,7 @@ func TestCache(t *testing.T) {
290297
assertFormatted(t, as, out, 0)
291298

292299
// clear cache
293-
out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c")
300+
_, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c")
294301
as.NoError(err)
295302
assertStats(t, as, 31, 31, 31, 0)
296303

@@ -299,7 +306,7 @@ func TestCache(t *testing.T) {
299306
assertFormatted(t, as, out, 0)
300307

301308
// no cache
302-
out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "--no-cache")
309+
_, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "--no-cache")
303310
as.NoError(err)
304311
assertStats(t, as, 31, 31, 31, 0)
305312
}

‎format/formatter.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ type Formatter struct {
3131
// internal compiled versions of Includes and Excludes.
3232
includes []glob.Glob
3333
excludes []glob.Glob
34-
35-
batch []string
3634
}
3735

3836
// Executable returns the path to the executable defined by Command
@@ -80,7 +78,7 @@ func (f *Formatter) Apply(ctx context.Context, tasks []*Task) error {
8078

8179
//
8280

83-
f.log.Infof("%v files processed in %v", len(tasks), time.Now().Sub(start))
81+
f.log.Infof("%v files processed in %v", len(tasks), time.Since(start))
8482

8583
return nil
8684
}

‎nix/devshell.nix

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# golang
2929
go
3030
goreleaser
31+
golangci-lint
3132
delve
3233
pprof
3334
graphviz

‎stats/stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Value(t Type) int32 {
4242
}
4343

4444
func Elapsed() time.Duration {
45-
return time.Now().Sub(start)
45+
return time.Since(start)
4646
}
4747

4848
func Print() {

‎walk/filesystem.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (f filesystemWalker) Walk(_ context.Context, fn WalkFunc) error {
2828
return filepath.Rel(f.root, path)
2929
}
3030

31-
walkFn := func(path string, info fs.FileInfo, err error) error {
31+
walkFn := func(path string, info fs.FileInfo, _ error) error {
3232
if info == nil {
3333
return fmt.Errorf("no such file or directory '%s'", path)
3434
}

‎walk/git.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (g *gitWalker) Walk(ctx context.Context, fn WalkFunc) error {
8888
continue
8989
}
9090

91-
return filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
91+
return filepath.Walk(path, func(path string, info fs.FileInfo, _ error) error {
9292
if info.IsDir() {
9393
return nil
9494
}

0 commit comments

Comments
 (0)
Please sign in to comment.