Skip to content

Commit 2e96829

Browse files
committed
Add gocritic to linters
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 923e01d commit 2e96829

File tree

8 files changed

+55
-50
lines changed

8 files changed

+55
-50
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ linters:
77
- deadcode
88
- depguard
99
- errcheck
10+
- gocritic
1011
- gocyclo
1112
- gofmt
1213
- goimports

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
# limitations under the License.
1717

1818
ARG GO_VERSION=1.18.4-alpine
19-
ARG GOLANGCI_LINT_VERSION=v1.40.1-alpine
19+
ARG GOLANGCI_LINT_VERSION=v1.46.2-alpine
2020
ARG PROTOC_GEN_GO_VERSION=v1.4.3
2121

22+
FROM --platform=${BUILDPLATFORM} golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS local-golangci-lint
23+
2224
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
2325
WORKDIR /compose-cli
2426
RUN apk add --no-cache -vv \
@@ -34,7 +36,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3436

3537
FROM base AS lint
3638
ENV CGO_ENABLED=0
37-
COPY --from=golangci/golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
39+
COPY --from=local-golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
3840
ARG BUILD_TAGS
3941
ARG GIT_TAG
4042
RUN --mount=target=. \

cmd/compose/down.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
6969
flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.")
7070
flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`)
7171
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
72-
switch name {
73-
case "volume":
72+
if name == "volume" {
7473
name = "volumes"
7574
logrus.Warn("--volume is deprecated, please use --volumes")
7675
}

pkg/api/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
const (
24-
//ExitCodeLoginRequired exit code when command cannot execute because it requires cloud login
24+
// ExitCodeLoginRequired exit code when command cannot execute because it requires cloud login
2525
// This will be used by VSCode to detect when creating context if the user needs to login first
2626
ExitCodeLoginRequired = 5
2727
)

pkg/compose/ls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ func combinedStatus(statuses []string) string {
106106
for _, status := range keys {
107107
nb := nbByStatus[status]
108108
if result != "" {
109-
result = result + ", "
109+
result += ", "
110110
}
111-
result = result + fmt.Sprintf("%s(%d)", status, nb)
111+
result += fmt.Sprintf("%s(%d)", status, nb)
112112
}
113113
return result
114114
}

pkg/compose/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ var (
5050
ComposeParseFailure = FailureCategory{MetricsStatus: ComposeParseFailureStatus, ExitCode: 15}
5151
// CommandSyntaxFailure failure for command line syntax
5252
CommandSyntaxFailure = FailureCategory{MetricsStatus: CommandSyntaxFailureStatus, ExitCode: 16}
53-
//BuildFailure failure while building images.
53+
// BuildFailure failure while building images.
5454
BuildFailure = FailureCategory{MetricsStatus: BuildFailureStatus, ExitCode: 17}
5555
// PullFailure failure while pulling image
5656
PullFailure = FailureCategory{MetricsStatus: PullFailureStatus, ExitCode: 18}
5757
)
5858

59-
//ByExitCode retrieve FailureCategory based on command exit code
59+
// ByExitCode retrieve FailureCategory based on command exit code
6060
func ByExitCode(exitCode int) FailureCategory {
6161
switch exitCode {
6262
case 0:

pkg/e2e/framework.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ var (
4646

4747
// DockerScanExecutableName is the OS dependent Docker CLI binary name
4848
DockerScanExecutableName = "docker-scan"
49+
50+
// WindowsExecutableSuffix is the Windows executable suffix
51+
WindowsExecutableSuffix = ".exe"
4952
)
5053

5154
func init() {
5255
if runtime.GOOS == "windows" {
53-
DockerExecutableName = DockerExecutableName + ".exe"
54-
DockerComposeExecutableName = DockerComposeExecutableName + ".exe"
55-
DockerScanExecutableName = DockerScanExecutableName + ".exe"
56+
DockerExecutableName += WindowsExecutableSuffix
57+
DockerComposeExecutableName += WindowsExecutableSuffix
58+
DockerScanExecutableName += WindowsExecutableSuffix
5659
}
5760
}
5861

pkg/progress/event.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,99 +44,99 @@ type Event struct {
4444
}
4545

4646
// ErrorMessageEvent creates a new Error Event with message
47-
func ErrorMessageEvent(ID string, msg string) Event {
48-
return NewEvent(ID, Error, msg)
47+
func ErrorMessageEvent(id string, msg string) Event {
48+
return NewEvent(id, Error, msg)
4949
}
5050

5151
// ErrorEvent creates a new Error Event
52-
func ErrorEvent(ID string) Event {
53-
return NewEvent(ID, Error, "Error")
52+
func ErrorEvent(id string) Event {
53+
return NewEvent(id, Error, "Error")
5454
}
5555

5656
// CreatingEvent creates a new Create in progress Event
57-
func CreatingEvent(ID string) Event {
58-
return NewEvent(ID, Working, "Creating")
57+
func CreatingEvent(id string) Event {
58+
return NewEvent(id, Working, "Creating")
5959
}
6060

6161
// StartingEvent creates a new Starting in progress Event
62-
func StartingEvent(ID string) Event {
63-
return NewEvent(ID, Working, "Starting")
62+
func StartingEvent(id string) Event {
63+
return NewEvent(id, Working, "Starting")
6464
}
6565

6666
// StartedEvent creates a new Started in progress Event
67-
func StartedEvent(ID string) Event {
68-
return NewEvent(ID, Done, "Started")
67+
func StartedEvent(id string) Event {
68+
return NewEvent(id, Done, "Started")
6969
}
7070

7171
// Waiting creates a new waiting event
72-
func Waiting(ID string) Event {
73-
return NewEvent(ID, Working, "Waiting")
72+
func Waiting(id string) Event {
73+
return NewEvent(id, Working, "Waiting")
7474
}
7575

7676
// Healthy creates a new healthy event
77-
func Healthy(ID string) Event {
78-
return NewEvent(ID, Done, "Healthy")
77+
func Healthy(id string) Event {
78+
return NewEvent(id, Done, "Healthy")
7979
}
8080

8181
// Exited creates a new exited event
82-
func Exited(ID string) Event {
83-
return NewEvent(ID, Done, "Exited")
82+
func Exited(id string) Event {
83+
return NewEvent(id, Done, "Exited")
8484
}
8585

8686
// RestartingEvent creates a new Restarting in progress Event
87-
func RestartingEvent(ID string) Event {
88-
return NewEvent(ID, Working, "Restarting")
87+
func RestartingEvent(id string) Event {
88+
return NewEvent(id, Working, "Restarting")
8989
}
9090

9191
// RestartedEvent creates a new Restarted in progress Event
92-
func RestartedEvent(ID string) Event {
93-
return NewEvent(ID, Done, "Restarted")
92+
func RestartedEvent(id string) Event {
93+
return NewEvent(id, Done, "Restarted")
9494
}
9595

9696
// RunningEvent creates a new Running in progress Event
97-
func RunningEvent(ID string) Event {
98-
return NewEvent(ID, Done, "Running")
97+
func RunningEvent(id string) Event {
98+
return NewEvent(id, Done, "Running")
9999
}
100100

101101
// CreatedEvent creates a new Created (done) Event
102-
func CreatedEvent(ID string) Event {
103-
return NewEvent(ID, Done, "Created")
102+
func CreatedEvent(id string) Event {
103+
return NewEvent(id, Done, "Created")
104104
}
105105

106106
// StoppingEvent creates a new Stopping in progress Event
107-
func StoppingEvent(ID string) Event {
108-
return NewEvent(ID, Working, "Stopping")
107+
func StoppingEvent(id string) Event {
108+
return NewEvent(id, Working, "Stopping")
109109
}
110110

111111
// StoppedEvent creates a new Stopping in progress Event
112-
func StoppedEvent(ID string) Event {
113-
return NewEvent(ID, Done, "Stopped")
112+
func StoppedEvent(id string) Event {
113+
return NewEvent(id, Done, "Stopped")
114114
}
115115

116116
// KillingEvent creates a new Killing in progress Event
117-
func KillingEvent(ID string) Event {
118-
return NewEvent(ID, Working, "Killing")
117+
func KillingEvent(id string) Event {
118+
return NewEvent(id, Working, "Killing")
119119
}
120120

121121
// KilledEvent creates a new Killed in progress Event
122-
func KilledEvent(ID string) Event {
123-
return NewEvent(ID, Done, "Killed")
122+
func KilledEvent(id string) Event {
123+
return NewEvent(id, Done, "Killed")
124124
}
125125

126126
// RemovingEvent creates a new Removing in progress Event
127-
func RemovingEvent(ID string) Event {
128-
return NewEvent(ID, Working, "Removing")
127+
func RemovingEvent(id string) Event {
128+
return NewEvent(id, Working, "Removing")
129129
}
130130

131131
// RemovedEvent creates a new removed (done) Event
132-
func RemovedEvent(ID string) Event {
133-
return NewEvent(ID, Done, "Removed")
132+
func RemovedEvent(id string) Event {
133+
return NewEvent(id, Done, "Removed")
134134
}
135135

136136
// NewEvent new event
137-
func NewEvent(ID string, status EventStatus, statusText string) Event {
137+
func NewEvent(id string, status EventStatus, statusText string) Event {
138138
return Event{
139-
ID: ID,
139+
ID: id,
140140
Status: status,
141141
StatusText: statusText,
142142
}

0 commit comments

Comments
 (0)