Skip to content

Commit

Permalink
Add gocritic to linters
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
  • Loading branch information
ulyssessouza committed Jul 13, 2022
1 parent 341e439 commit b511046
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dotenv/godotenv.go
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions golangci.yml
Expand Up @@ -4,6 +4,7 @@ run:
linters:
disable-all: true
enable:
- gocritic
- gofmt
- goimports
- revive
Expand Down
2 changes: 1 addition & 1 deletion loader/full-struct_test.go
Expand Up @@ -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"),
Expand Down
6 changes: 2 additions & 4 deletions loader/loader.go
Expand Up @@ -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 != "":
Expand Down
9 changes: 3 additions & 6 deletions loader/validate.go
Expand Up @@ -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))
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions types/types.go
Expand Up @@ -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"
)

Expand Down

0 comments on commit b511046

Please sign in to comment.