diff --git a/cli/format_test.go b/cli/format_test.go index 8196361..e77acb8 100644 --- a/cli/format_test.go +++ b/cli/format_test.go @@ -49,7 +49,7 @@ func TestOnUnmatched(t *testing.T) { // - "haskell/treefmt.toml" } - out, err := cmd(t, "-C", tempDir, "--allow-missing-formatter", "--on-unmatched", "fatal") + _, err = cmd(t, "-C", tempDir, "--allow-missing-formatter", "--on-unmatched", "fatal") as.ErrorContains(err, fmt.Sprintf("no formatter for path: %s", paths[0])) checkOutput := func(level string, output []byte) { @@ -58,6 +58,8 @@ func TestOnUnmatched(t *testing.T) { } } + var out []byte + // default is warn out, err = cmd(t, "-C", tempDir, "--allow-missing-formatter", "-c") as.NoError(err) @@ -271,8 +273,13 @@ func TestCache(t *testing.T) { }, } + var ( + out []byte + err error + ) + test.WriteConfig(t, configPath, cfg) - out, err := cmd(t, "--config-file", configPath, "--tree-root", tempDir) + _, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir) as.NoError(err) assertStats(t, as, 31, 31, 31, 0) @@ -281,7 +288,7 @@ func TestCache(t *testing.T) { assertFormatted(t, as, out, 0) // clear cache - out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c") + _, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c") as.NoError(err) assertStats(t, as, 31, 31, 31, 0) @@ -290,7 +297,7 @@ func TestCache(t *testing.T) { assertFormatted(t, as, out, 0) // clear cache - out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c") + _, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "-c") as.NoError(err) assertStats(t, as, 31, 31, 31, 0) @@ -299,7 +306,7 @@ func TestCache(t *testing.T) { assertFormatted(t, as, out, 0) // no cache - out, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "--no-cache") + _, err = cmd(t, "--config-file", configPath, "--tree-root", tempDir, "--no-cache") as.NoError(err) assertStats(t, as, 31, 31, 31, 0) } diff --git a/format/formatter.go b/format/formatter.go index a01646e..6cf2eb9 100644 --- a/format/formatter.go +++ b/format/formatter.go @@ -31,8 +31,6 @@ type Formatter struct { // internal compiled versions of Includes and Excludes. includes []glob.Glob excludes []glob.Glob - - batch []string } // Executable returns the path to the executable defined by Command @@ -80,7 +78,7 @@ func (f *Formatter) Apply(ctx context.Context, tasks []*Task) error { // - f.log.Infof("%v files processed in %v", len(tasks), time.Now().Sub(start)) + f.log.Infof("%v files processed in %v", len(tasks), time.Since(start)) return nil } diff --git a/nix/devshell.nix b/nix/devshell.nix index b7c9d55..1904f38 100644 --- a/nix/devshell.nix +++ b/nix/devshell.nix @@ -28,6 +28,7 @@ # golang go goreleaser + golangci-lint delve pprof graphviz diff --git a/stats/stats.go b/stats/stats.go index 63fdf64..d15af95 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -42,7 +42,7 @@ func Value(t Type) int32 { } func Elapsed() time.Duration { - return time.Now().Sub(start) + return time.Since(start) } func Print() { diff --git a/walk/filesystem.go b/walk/filesystem.go index d2db1a4..18cc3df 100644 --- a/walk/filesystem.go +++ b/walk/filesystem.go @@ -28,7 +28,7 @@ func (f filesystemWalker) Walk(_ context.Context, fn WalkFunc) error { return filepath.Rel(f.root, path) } - walkFn := func(path string, info fs.FileInfo, err error) error { + walkFn := func(path string, info fs.FileInfo, _ error) error { if info == nil { return fmt.Errorf("no such file or directory '%s'", path) } diff --git a/walk/git.go b/walk/git.go index f5e60a9..58afa4e 100644 --- a/walk/git.go +++ b/walk/git.go @@ -88,7 +88,7 @@ func (g *gitWalker) Walk(ctx context.Context, fn WalkFunc) error { continue } - return filepath.Walk(path, func(path string, info fs.FileInfo, err error) error { + return filepath.Walk(path, func(path string, info fs.FileInfo, _ error) error { if info.IsDir() { return nil }