mirror of
https://github.com/go-task/task.git
synced 2024-12-04 10:24:45 +02:00
refactor: enable gofmt linter and fix all issues
- also rewrite 'interface{}' as 'any'
This commit is contained in:
parent
a6d57496c2
commit
aab51c331f
@ -6,7 +6,12 @@
|
||||
linters:
|
||||
enable:
|
||||
- goimports
|
||||
- gofmt
|
||||
|
||||
linters-settings:
|
||||
goimports:
|
||||
local-prefixes: github.com/go-task/task
|
||||
gofmt:
|
||||
rewrite-rules:
|
||||
- pattern: 'interface{}'
|
||||
replacement: 'any'
|
||||
|
@ -34,9 +34,9 @@ func TestArgsV3(t *testing.T) {
|
||||
ExpectedGlobals: &taskfile.Vars{
|
||||
Keys: []string{"FOO", "BAR", "BAZ"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"FOO": taskfile.Var{Static: "bar"},
|
||||
"BAR": taskfile.Var{Static: "baz"},
|
||||
"BAZ": taskfile.Var{Static: "foo"},
|
||||
"FOO": {Static: "bar"},
|
||||
"BAR": {Static: "baz"},
|
||||
"BAZ": {Static: "foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -48,7 +48,7 @@ func TestArgsV3(t *testing.T) {
|
||||
ExpectedGlobals: &taskfile.Vars{
|
||||
Keys: []string{"CONTENT"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"CONTENT": taskfile.Var{Static: "with some spaces"},
|
||||
"CONTENT": {Static: "with some spaces"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -125,7 +125,7 @@ func TestArgsV2(t *testing.T) {
|
||||
Vars: &taskfile.Vars{
|
||||
Keys: []string{"FOO"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"FOO": taskfile.Var{Static: "bar"},
|
||||
"FOO": {Static: "bar"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -135,8 +135,8 @@ func TestArgsV2(t *testing.T) {
|
||||
Vars: &taskfile.Vars{
|
||||
Keys: []string{"BAR", "BAZ"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"BAR": taskfile.Var{Static: "baz"},
|
||||
"BAZ": taskfile.Var{Static: "foo"},
|
||||
"BAR": {Static: "baz"},
|
||||
"BAZ": {Static: "foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -150,7 +150,7 @@ func TestArgsV2(t *testing.T) {
|
||||
Vars: &taskfile.Vars{
|
||||
Keys: []string{"CONTENT"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"CONTENT": taskfile.Var{Static: "with some spaces"},
|
||||
"CONTENT": {Static: "with some spaces"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ type StatusCheckable interface {
|
||||
// SourcesCheckable defines any type that can check if the sources of a task are up-to-date.
|
||||
type SourcesCheckable interface {
|
||||
IsUpToDate(t *taskfile.Task) (bool, error)
|
||||
Value(t *taskfile.Task) (interface{}, error)
|
||||
Value(t *taskfile.Task) (any, error)
|
||||
OnError(t *taskfile.Task) error
|
||||
Kind() string
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: checker.go
|
||||
// Source: internal/fingerprint/checker.go
|
||||
|
||||
// Package fingerprint is a generated GoMock package.
|
||||
package fingerprint
|
||||
@ -117,10 +117,10 @@ func (mr *MockSourcesCheckableMockRecorder) OnError(t interface{}) *gomock.Call
|
||||
}
|
||||
|
||||
// Value mocks base method.
|
||||
func (m *MockSourcesCheckable) Value(t *taskfile.Task) (interface{}, error) {
|
||||
func (m *MockSourcesCheckable) Value(t *taskfile.Task) (any, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Value", t)
|
||||
ret0, _ := ret[0].(interface{})
|
||||
ret0, _ := ret[0].(any)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (checker *ChecksumChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
|
||||
return oldMd5 == newMd5, nil
|
||||
}
|
||||
|
||||
func (checker *ChecksumChecker) Value(t *taskfile.Task) (interface{}, error) {
|
||||
func (checker *ChecksumChecker) Value(t *taskfile.Task) (any, error) {
|
||||
return checker.checksum(t)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ func (NoneChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (NoneChecker) Value(t *taskfile.Task) (interface{}, error) {
|
||||
func (NoneChecker) Value(t *taskfile.Task) (any, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ func (checker *TimestampChecker) Kind() string {
|
||||
}
|
||||
|
||||
// Value implements the Checker Interface
|
||||
func (checker *TimestampChecker) Value(t *taskfile.Task) (interface{}, error) {
|
||||
func (checker *TimestampChecker) Value(t *taskfile.Task) (any, error) {
|
||||
sources, err := globs(t.Dir, t.Sources)
|
||||
if err != nil {
|
||||
return time.Now(), err
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Color func() PrintFunc
|
||||
type PrintFunc func(io.Writer, string, ...interface{})
|
||||
type PrintFunc func(io.Writer, string, ...any)
|
||||
|
||||
func Default() PrintFunc {
|
||||
return color.New(envColor("TASK_COLOR_RESET", color.Reset)).FprintfFunc()
|
||||
@ -56,14 +56,14 @@ type Logger struct {
|
||||
}
|
||||
|
||||
// Outf prints stuff to STDOUT.
|
||||
func (l *Logger) Outf(color Color, s string, args ...interface{}) {
|
||||
func (l *Logger) Outf(color Color, s string, args ...any) {
|
||||
l.FOutf(l.Stdout, color, s+"\n", args...)
|
||||
}
|
||||
|
||||
// FOutf prints stuff to the given writer.
|
||||
func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...interface{}) {
|
||||
func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...any) {
|
||||
if len(args) == 0 {
|
||||
s, args = "%s", []interface{}{s}
|
||||
s, args = "%s", []any{s}
|
||||
}
|
||||
if !l.Color {
|
||||
color = Default
|
||||
@ -73,16 +73,16 @@ func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...interface{})
|
||||
}
|
||||
|
||||
// VerboseOutf prints stuff to STDOUT if verbose mode is enabled.
|
||||
func (l *Logger) VerboseOutf(color Color, s string, args ...interface{}) {
|
||||
func (l *Logger) VerboseOutf(color Color, s string, args ...any) {
|
||||
if l.Verbose {
|
||||
l.Outf(color, s, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Errf prints stuff to STDERR.
|
||||
func (l *Logger) Errf(color Color, s string, args ...interface{}) {
|
||||
func (l *Logger) Errf(color Color, s string, args ...any) {
|
||||
if len(args) == 0 {
|
||||
s, args = "%s", []interface{}{s}
|
||||
s, args = "%s", []any{s}
|
||||
}
|
||||
if !l.Color {
|
||||
color = Default
|
||||
@ -92,7 +92,7 @@ func (l *Logger) Errf(color Color, s string, args ...interface{}) {
|
||||
}
|
||||
|
||||
// VerboseErrf prints stuff to STDERR if verbose mode is enabled.
|
||||
func (l *Logger) VerboseErrf(color Color, s string, args ...interface{}) {
|
||||
func (l *Logger) VerboseErrf(color Color, s string, args ...any) {
|
||||
if l.Verbose {
|
||||
l.Errf(color, s, args...)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type Templater struct {
|
||||
Vars *taskfile.Vars
|
||||
RemoveNoValue bool
|
||||
|
||||
cacheMap map[string]interface{}
|
||||
cacheMap map[string]any
|
||||
err error
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
func TestPreconditionParse(t *testing.T) {
|
||||
tests := []struct {
|
||||
content string
|
||||
v interface{}
|
||||
expected interface{}
|
||||
v any
|
||||
expected any
|
||||
}{
|
||||
{
|
||||
"test -f foo.txt",
|
||||
|
@ -24,8 +24,8 @@ vars:
|
||||
)
|
||||
tests := []struct {
|
||||
content string
|
||||
v interface{}
|
||||
expected interface{}
|
||||
v any
|
||||
expected any
|
||||
}{
|
||||
{
|
||||
yamlCmd,
|
||||
@ -38,8 +38,8 @@ vars:
|
||||
&taskfile.Cmd{Task: "another-task", Vars: &taskfile.Vars{
|
||||
Keys: []string{"PARAM1", "PARAM2"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"PARAM1": taskfile.Var{Static: "VALUE1"},
|
||||
"PARAM2": taskfile.Var{Static: "VALUE2"},
|
||||
"PARAM1": {Static: "VALUE1"},
|
||||
"PARAM2": {Static: "VALUE2"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
@ -54,7 +54,7 @@ vars:
|
||||
&taskfile.Cmd{Task: "some_task", Vars: &taskfile.Vars{
|
||||
Keys: []string{"PARAM1"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"PARAM1": taskfile.Var{Static: "var"},
|
||||
"PARAM1": {Static: "var"},
|
||||
},
|
||||
}, Defer: true},
|
||||
},
|
||||
@ -69,8 +69,8 @@ vars:
|
||||
&taskfile.Dep{Task: "another-task", Vars: &taskfile.Vars{
|
||||
Keys: []string{"PARAM1", "PARAM2"},
|
||||
Mapping: map[string]taskfile.Var{
|
||||
"PARAM1": taskfile.Var{Static: "VALUE1"},
|
||||
"PARAM2": taskfile.Var{Static: "VALUE2"},
|
||||
"PARAM1": {Static: "VALUE1"},
|
||||
"PARAM2": {Static: "VALUE2"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
|
@ -82,8 +82,8 @@ func (vs *Vars) Range(yield func(key string, value Var) error) error {
|
||||
|
||||
// ToCacheMap converts Vars to a map containing only the static
|
||||
// variables
|
||||
func (vs *Vars) ToCacheMap() (m map[string]interface{}) {
|
||||
m = make(map[string]interface{}, vs.Len())
|
||||
func (vs *Vars) ToCacheMap() (m map[string]any) {
|
||||
m = make(map[string]any, vs.Len())
|
||||
_ = vs.Range(func(k string, v Var) error {
|
||||
if v.Sh != "" {
|
||||
// Dynamic variable is not yet resolved; trigger
|
||||
@ -112,7 +112,7 @@ func (vs *Vars) Len() int {
|
||||
// Var represents either a static or dynamic variable.
|
||||
type Var struct {
|
||||
Static string
|
||||
Live interface{}
|
||||
Live any
|
||||
Sh string
|
||||
Dir string
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user