Merge pull request #320 from numtide/golangci-lint

chore: do a golangci-lint pass
This commit is contained in:
Brian McGee 2024-06-14 14:20:32 +01:00 committed by GitHub
commit 4e8daacca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 11 deletions

View File

@ -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)
}

View File

@ -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
}

View File

@ -28,6 +28,7 @@
# golang
go
goreleaser
golangci-lint
delve
pprof
graphviz

View File

@ -42,7 +42,7 @@ func Value(t Type) int32 {
}
func Elapsed() time.Duration {
return time.Now().Sub(start)
return time.Since(start)
}
func Print() {

View File

@ -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)
}

View File

@ -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
}