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