mirror of
https://github.com/go-task/task.git
synced 2025-03-17 21:08:01 +02:00
Fix go-critic suggestions
This commit is contained in:
parent
c172185a24
commit
b08eac58e9
@ -17,7 +17,7 @@ type taskNotFoundError struct {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -26,7 +26,7 @@ type TaskRunError struct {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -46,7 +46,7 @@ type MaximumTaskCallExceededError struct {
|
||||
|
||||
func (e *MaximumTaskCallExceededError) Error() string {
|
||||
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,
|
||||
e.task,
|
||||
)
|
||||
|
2
init.go
2
init.go
@ -30,7 +30,7 @@ func InitTaskfile(w io.Writer, dir string) error {
|
||||
return ErrTaskfileAlreadyExists
|
||||
}
|
||||
|
||||
if err := os.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil {
|
||||
if err := os.WriteFile(f, []byte(defaultTaskfile), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(w, "Taskfile.yaml created in the current directory\n")
|
||||
|
@ -73,7 +73,7 @@ func IsExitError(err error) bool {
|
||||
// if available.
|
||||
func Expand(s string) (string, error) {
|
||||
s = filepath.ToSlash(s)
|
||||
s = strings.Replace(s, " ", `\ `, -1)
|
||||
s = strings.ReplaceAll(s, " ", `\ `)
|
||||
fields, err := shell.Fields(s, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -45,8 +45,8 @@ func (c *Checksum) IsUpToDate() (bool, error) {
|
||||
}
|
||||
|
||||
if !c.Dry {
|
||||
_ = os.MkdirAll(filepathext.SmartJoin(c.TempDir, "checksum"), 0755)
|
||||
if err = os.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil {
|
||||
_ = os.MkdirAll(filepathext.SmartJoin(c.TempDir, "checksum"), 0o755)
|
||||
if err = os.WriteFile(checksumFile, []byte(newMd5+"\n"), 0o644); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ func init() {
|
||||
"OS": func() string { return runtime.GOOS },
|
||||
"ARCH": func() string { return runtime.GOARCH },
|
||||
"catLines": func(s string) string {
|
||||
s = strings.Replace(s, "\r\n", " ", -1)
|
||||
return strings.Replace(s, "\n", " ", -1)
|
||||
s = strings.ReplaceAll(s, "\r\n", " ")
|
||||
return strings.ReplaceAll(s, "\n", " ")
|
||||
},
|
||||
"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")
|
||||
},
|
||||
"fromSlash": func(path string) string {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
func (e *Executor) InterceptInterruptSignals() {
|
||||
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()
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ func TestSummary(t *testing.T) {
|
||||
|
||||
expectedOutput := string(data)
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user