Skip to content

Commit edde9c6

Browse files
committed
Add gocritic to linters
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 045c678 commit edde9c6

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

dotenv/godotenv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func doubleQuoteEscape(line string) string {
353353
if c == '\r' {
354354
toReplace = `\r`
355355
}
356-
line = strings.Replace(line, string(c), toReplace, -1)
356+
line = strings.ReplaceAll(line, string(c), toReplace)
357357
}
358358
return line
359359
}

golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ run:
44
linters:
55
disable-all: true
66
enable:
7+
- gocritic
78
- gofmt
89
- goimports
910
- revive

loader/full-struct_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ x-nested:
10031003
bar: baz
10041004
foo: bar
10051005
`,
1006-
filepath.Join(workingDir),
1006+
workingDir,
10071007
filepath.Join(workingDir, "static"),
10081008
filepath.Join(homeDir, "configs"),
10091009
filepath.Join(workingDir, "opt"),

loader/loader.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,8 @@ func loadFileObjectConfig(name string, objType string, obj types.FileObjectConfi
810810
logrus.Warnf("%[1]s %[2]s: %[1]s.external.name is deprecated in favor of %[1]s.name", objType, name)
811811
obj.Name = obj.External.Name
812812
obj.External.Name = ""
813-
} else {
814-
if obj.Name == "" {
815-
obj.Name = name
816-
}
813+
} else if obj.Name == "" {
814+
obj.Name = name
817815
}
818816
// if not "external: true"
819817
case obj.Driver != "":

loader/validate.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ func checkConsistency(project *types.Project) error {
5252
}
5353

5454
for _, volume := range s.Volumes {
55-
switch volume.Type {
56-
case types.VolumeTypeVolume:
57-
if volume.Source != "" { // non anonymous volumes
58-
if _, ok := project.Volumes[volume.Source]; !ok {
59-
return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined volume %s", s.Name, volume.Source))
60-
}
55+
if volume.Type == types.VolumeTypeVolume && volume.Source != "" { // non anonymous volumes
56+
if _, ok := project.Volumes[volume.Source]; !ok {
57+
return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined volume %s", s.Name, volume.Source))
6158
}
6259
}
6360
}

types/types.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,26 +204,26 @@ func (s *ServiceConfig) NetworksByPriority() []string {
204204
}
205205

206206
const (
207-
//PullPolicyAlways always pull images
207+
// PullPolicyAlways always pull images
208208
PullPolicyAlways = "always"
209-
//PullPolicyNever never pull images
209+
// PullPolicyNever never pull images
210210
PullPolicyNever = "never"
211-
//PullPolicyIfNotPresent pull missing images
211+
// PullPolicyIfNotPresent pull missing images
212212
PullPolicyIfNotPresent = "if_not_present"
213-
//PullPolicyMissing pull missing images
213+
// PullPolicyMissing pull missing images
214214
PullPolicyMissing = "missing"
215-
//PullPolicyBuild force building images
215+
// PullPolicyBuild force building images
216216
PullPolicyBuild = "build"
217217
)
218218

219219
const (
220-
//RestartPolicyAlways always restart the container if it stops
220+
// RestartPolicyAlways always restart the container if it stops
221221
RestartPolicyAlways = "always"
222-
//RestartPolicyOnFailure restart the container if it exits due to an error
222+
// RestartPolicyOnFailure restart the container if it exits due to an error
223223
RestartPolicyOnFailure = "on-failure"
224-
//RestartPolicyNo do not automatically restart the container
224+
// RestartPolicyNo do not automatically restart the container
225225
RestartPolicyNo = "no"
226-
//RestartPolicyUnlessStopped always restart the container unless the container is stopped (manually or otherwise)
226+
// RestartPolicyUnlessStopped always restart the container unless the container is stopped (manually or otherwise)
227227
RestartPolicyUnlessStopped = "unless-stopped"
228228
)
229229

0 commit comments

Comments
 (0)