diff --git a/dotenv/godotenv.go b/dotenv/godotenv.go index 98d662051..78c1c9ca3 100644 --- a/dotenv/godotenv.go +++ b/dotenv/godotenv.go @@ -353,7 +353,7 @@ func doubleQuoteEscape(line string) string { if c == '\r' { toReplace = `\r` } - line = strings.Replace(line, string(c), toReplace, -1) + line = strings.ReplaceAll(line, string(c), toReplace) } return line } diff --git a/golangci.yml b/golangci.yml index 2d3fce664..5d708d42d 100644 --- a/golangci.yml +++ b/golangci.yml @@ -4,6 +4,7 @@ run: linters: disable-all: true enable: + - gocritic - gofmt - goimports - revive diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go index 42f8c03b2..9259d467d 100644 --- a/loader/full-struct_test.go +++ b/loader/full-struct_test.go @@ -1003,7 +1003,7 @@ x-nested: bar: baz foo: bar `, - filepath.Join(workingDir), + workingDir, filepath.Join(workingDir, "static"), filepath.Join(homeDir, "configs"), filepath.Join(workingDir, "opt"), diff --git a/loader/loader.go b/loader/loader.go index 2c115e3c1..73da8e3e7 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -810,10 +810,8 @@ func loadFileObjectConfig(name string, objType string, obj types.FileObjectConfi logrus.Warnf("%[1]s %[2]s: %[1]s.external.name is deprecated in favor of %[1]s.name", objType, name) obj.Name = obj.External.Name obj.External.Name = "" - } else { - if obj.Name == "" { - obj.Name = name - } + } else if obj.Name == "" { + obj.Name = name } // if not "external: true" case obj.Driver != "": diff --git a/loader/validate.go b/loader/validate.go index e88d14b57..4d635889d 100644 --- a/loader/validate.go +++ b/loader/validate.go @@ -52,12 +52,9 @@ func checkConsistency(project *types.Project) error { } for _, volume := range s.Volumes { - switch volume.Type { - case types.VolumeTypeVolume: - if volume.Source != "" { // non anonymous volumes - if _, ok := project.Volumes[volume.Source]; !ok { - return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined volume %s", s.Name, volume.Source)) - } + if volume.Type == types.VolumeTypeVolume && volume.Source != "" { // non anonymous volumes + if _, ok := project.Volumes[volume.Source]; !ok { + return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined volume %s", s.Name, volume.Source)) } } } diff --git a/types/types.go b/types/types.go index b54679e3f..34db0c6f3 100644 --- a/types/types.go +++ b/types/types.go @@ -204,26 +204,26 @@ func (s *ServiceConfig) NetworksByPriority() []string { } const ( - //PullPolicyAlways always pull images + // PullPolicyAlways always pull images PullPolicyAlways = "always" - //PullPolicyNever never pull images + // PullPolicyNever never pull images PullPolicyNever = "never" - //PullPolicyIfNotPresent pull missing images + // PullPolicyIfNotPresent pull missing images PullPolicyIfNotPresent = "if_not_present" - //PullPolicyMissing pull missing images + // PullPolicyMissing pull missing images PullPolicyMissing = "missing" - //PullPolicyBuild force building images + // PullPolicyBuild force building images PullPolicyBuild = "build" ) const ( - //RestartPolicyAlways always restart the container if it stops + // RestartPolicyAlways always restart the container if it stops RestartPolicyAlways = "always" - //RestartPolicyOnFailure restart the container if it exits due to an error + // RestartPolicyOnFailure restart the container if it exits due to an error RestartPolicyOnFailure = "on-failure" - //RestartPolicyNo do not automatically restart the container + // RestartPolicyNo do not automatically restart the container RestartPolicyNo = "no" - //RestartPolicyUnlessStopped always restart the container unless the container is stopped (manually or otherwise) + // RestartPolicyUnlessStopped always restart the container unless the container is stopped (manually or otherwise) RestartPolicyUnlessStopped = "unless-stopped" )