mirror of
https://github.com/numtide/treefmt.git
synced 2024-11-20 18:10:21 +03:00
Merge pull request #320 from numtide/golangci-lint
chore: do a golangci-lint pass
This commit is contained in:
commit
4e8daacca3
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
# golang
|
||||
go
|
||||
goreleaser
|
||||
golangci-lint
|
||||
delve
|
||||
pprof
|
||||
graphviz
|
||||
|
@ -42,7 +42,7 @@ func Value(t Type) int32 {
|
||||
}
|
||||
|
||||
func Elapsed() time.Duration {
|
||||
return time.Now().Sub(start)
|
||||
return time.Since(start)
|
||||
}
|
||||
|
||||
func Print() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user