mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
Merge pull request #841 from cristaloleg/fix-linter
Fix go-critic suggestions
This commit is contained in:
@@ -17,7 +17,7 @@ type taskNotFoundError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (err *taskNotFoundError) Error() string {
|
func (err *taskNotFoundError) Error() string {
|
||||||
return fmt.Sprintf(`task: Task "%s" not found`, err.taskName)
|
return fmt.Sprintf(`task: Task %q not found`, err.taskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskRunError struct {
|
type TaskRunError struct {
|
||||||
@@ -26,7 +26,7 @@ type TaskRunError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (err *TaskRunError) Error() string {
|
func (err *TaskRunError) Error() string {
|
||||||
return fmt.Sprintf(`task: Failed to run task "%s": %v`, err.taskName, err.err)
|
return fmt.Sprintf(`task: Failed to run task %q: %v`, err.taskName, err.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *TaskRunError) ExitCode() int {
|
func (err *TaskRunError) ExitCode() int {
|
||||||
@@ -46,7 +46,7 @@ type MaximumTaskCallExceededError struct {
|
|||||||
|
|
||||||
func (e *MaximumTaskCallExceededError) Error() string {
|
func (e *MaximumTaskCallExceededError) Error() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`task: maximum task call exceeded (%d) for task "%s": probably an cyclic dep or infinite loop`,
|
`task: maximum task call exceeded (%d) for task %q: probably an cyclic dep or infinite loop`,
|
||||||
MaximumTaskCall,
|
MaximumTaskCall,
|
||||||
e.task,
|
e.task,
|
||||||
)
|
)
|
||||||
|
2
init.go
2
init.go
@@ -30,7 +30,7 @@ func InitTaskfile(w io.Writer, dir string) error {
|
|||||||
return ErrTaskfileAlreadyExists
|
return ErrTaskfileAlreadyExists
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil {
|
if err := os.WriteFile(f, []byte(defaultTaskfile), 0o644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "Taskfile.yaml created in the current directory\n")
|
fmt.Fprintf(w, "Taskfile.yaml created in the current directory\n")
|
||||||
|
@@ -73,7 +73,7 @@ func IsExitError(err error) bool {
|
|||||||
// if available.
|
// if available.
|
||||||
func Expand(s string) (string, error) {
|
func Expand(s string) (string, error) {
|
||||||
s = filepath.ToSlash(s)
|
s = filepath.ToSlash(s)
|
||||||
s = strings.Replace(s, " ", `\ `, -1)
|
s = strings.ReplaceAll(s, " ", `\ `)
|
||||||
fields, err := shell.Fields(s, nil)
|
fields, err := shell.Fields(s, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@@ -45,8 +45,8 @@ func (c *Checksum) IsUpToDate() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.Dry {
|
if !c.Dry {
|
||||||
_ = os.MkdirAll(filepathext.SmartJoin(c.TempDir, "checksum"), 0755)
|
_ = os.MkdirAll(filepathext.SmartJoin(c.TempDir, "checksum"), 0o755)
|
||||||
if err = os.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil {
|
if err = os.WriteFile(checksumFile, []byte(newMd5+"\n"), 0o644); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,11 +19,11 @@ func init() {
|
|||||||
"OS": func() string { return runtime.GOOS },
|
"OS": func() string { return runtime.GOOS },
|
||||||
"ARCH": func() string { return runtime.GOARCH },
|
"ARCH": func() string { return runtime.GOARCH },
|
||||||
"catLines": func(s string) string {
|
"catLines": func(s string) string {
|
||||||
s = strings.Replace(s, "\r\n", " ", -1)
|
s = strings.ReplaceAll(s, "\r\n", " ")
|
||||||
return strings.Replace(s, "\n", " ", -1)
|
return strings.ReplaceAll(s, "\n", " ")
|
||||||
},
|
},
|
||||||
"splitLines": func(s string) []string {
|
"splitLines": func(s string) []string {
|
||||||
s = strings.Replace(s, "\r\n", "\n", -1)
|
s = strings.ReplaceAll(s, "\r\n", "\n")
|
||||||
return strings.Split(s, "\n")
|
return strings.Split(s, "\n")
|
||||||
},
|
},
|
||||||
"fromSlash": func(path string) string {
|
"fromSlash": func(path string) string {
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NOTE(@andreynering): This function intercepts SIGINT and SIGTERM signals
|
// NOTE(@andreynering): This function intercepts SIGINT and SIGTERM signals
|
||||||
// so the Task process is not killed immediatelly and processes running have
|
// so the Task process is not killed immediately and processes running have
|
||||||
// time to do cleanup work.
|
// time to do cleanup work.
|
||||||
func (e *Executor) InterceptInterruptSignals() {
|
func (e *Executor) InterceptInterruptSignals() {
|
||||||
ch := make(chan os.Signal, 3)
|
ch := make(chan os.Signal, 3)
|
||||||
|
2
task.go
2
task.go
@@ -181,7 +181,7 @@ func (e *Executor) mkdir(t *taskfile.Task) error {
|
|||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
|
|
||||||
if _, err := os.Stat(t.Dir); os.IsNotExist(err) {
|
if _, err := os.Stat(t.Dir); os.IsNotExist(err) {
|
||||||
if err := os.MkdirAll(t.Dir, 0755); err != nil {
|
if err := os.MkdirAll(t.Dir, 0o755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -970,7 +970,7 @@ func TestSummary(t *testing.T) {
|
|||||||
|
|
||||||
expectedOutput := string(data)
|
expectedOutput := string(data)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
expectedOutput = strings.Replace(expectedOutput, "\r\n", "\n", -1)
|
expectedOutput = strings.ReplaceAll(expectedOutput, "\r\n", "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, expectedOutput, buff.String())
|
assert.Equal(t, expectedOutput, buff.String())
|
||||||
|
Reference in New Issue
Block a user