Skip to content

Commit 1257be9

Browse files
committed
Fix golangci-lint static analysis failures
1 parent 76977ad commit 1257be9

File tree

15 files changed

+25
-30
lines changed

15 files changed

+25
-30
lines changed

commands/multi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (mr *RunCommand) Start(_ service.Service) error {
172172

173173
userModeWarning(false)
174174

175-
if len(mr.WorkingDirectory) > 0 {
175+
if mr.WorkingDirectory != "" {
176176
err := os.Chdir(mr.WorkingDirectory)
177177
if err != nil {
178178
return err

commands/reset_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (c *ResetTokenCommand) resetSingleRunnerToken() bool {
5252
}
5353

5454
func (c *ResetTokenCommand) getRunnerCredentials() (*common.RunnerCredentials, error) {
55-
if len(c.Name) > 0 {
55+
if c.Name != "" {
5656
runnerConfig, err := c.RunnerByName(c.Name)
5757
if err != nil {
5858
return nil, err

common/build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,8 @@ func (b *Build) expandContainerOptions() {
12761276
}
12771277
}
12781278

1279-
func (b *Build) getURLWithAuth(URL string) string {
1280-
u, _ := url.Parse(URL)
1279+
func (b *Build) getURLWithAuth(repoURL string) string {
1280+
u, _ := url.Parse(repoURL)
12811281

12821282
if u.Scheme == "ssh" {
12831283
if u.User == nil {

common/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ func (s *KubernetesPodSpec) PodSpecPatch() ([]byte, KubernetesPodSpecPatchType,
667667
}
668668

669669
if s.PatchPath != "" {
670-
if len(s.Patch) > 0 {
670+
if s.Patch != "" {
671671
return nil, "", fmt.Errorf("%w (%s)", errPatchAmbiguous, s.Name)
672672
}
673673

executors/docker/internal/volumes/manager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestDefaultManager_CreateUserVolumes_HostVolume(t *testing.T) {
139139
err := m.Create(context.Background(), existingBinding)
140140
require.NoError(t, err)
141141

142-
if len(testCase.volume) > 0 {
142+
if testCase.volume != "" {
143143
volumeParser.On("ParseVolume", testCase.volume).
144144
Return(testCase.parsedVolume, nil).
145145
Once()
@@ -215,7 +215,7 @@ func TestDefaultManager_CreateUserVolumes_CacheVolume_Disabled(t *testing.T) {
215215
err := m.Create(context.Background(), "/host:/duplicated")
216216
require.NoError(t, err)
217217

218-
if len(testCase.volume) > 0 {
218+
if testCase.volume != "" {
219219
volumeParser.On("ParseVolume", testCase.volume).
220220
Return(testCase.parsedVolume, nil).
221221
Once()

executors/internal/autoscaler/acquisition_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,8 @@ func TestAcquisitionRef_Prepare(t *testing.T) {
223223
if tc.tunnelDialErr != nil || tc.mockNestingClientDelete {
224224
nestingClient.EXPECT().Delete(mock.Anything, testVM.id).Return(nil).Once()
225225
}
226-
} else {
227-
if tc.mockDialerClose {
228-
fleetingDialer.EXPECT().Close().Return(nil).Once()
229-
}
226+
} else if tc.mockDialerClose {
227+
fleetingDialer.EXPECT().Close().Return(nil).Once()
230228
}
231229

232230
logger, _ := test.NewNullLogger()

executors/kubernetes/kubernetes.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,11 @@ func (s *executor) buildPermissionsInitContainer(os string) (api.Container, erro
894894
}
895895

896896
func (s *executor) buildRedirectionCmd(shell string) string {
897-
switch shell {
898-
// powershell outputs utf16, so we re-encode the output to utf8
899-
// this is important because our json decoder that detects the exit status
900-
// of a job requires utf8.Converting command output to strings with %{"$_"}
901-
// prevents a powershell complaint about native command output on stderr.
902-
case shells.SNPowershell:
897+
if shell == shells.SNPowershell {
898+
// powershell outputs utf16, so we re-encode the output to utf8
899+
// this is important because our json decoder that detects the exit status
900+
// of a job requires utf8.Converting command output to strings with %{"$_"}
901+
// prevents a powershell complaint about native command output on stderr.
903902
return fmt.Sprintf("2>&1 | %%{ \"$_\" } | Out-File -Append -Encoding UTF8 %s", s.logFile())
904903
}
905904

@@ -2207,7 +2206,7 @@ func (s *executor) getDNSPolicy() api.DNSPolicy {
22072206
}
22082207

22092208
func (s *executor) getHelperImage() string {
2210-
if len(s.Config.Kubernetes.HelperImage) > 0 {
2209+
if s.Config.Kubernetes.HelperImage != "" {
22112210
return s.ExpandValue(s.Config.Kubernetes.HelperImage)
22122211
}
22132212

executors/kubernetes/kubernetes_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,8 @@ func TestCleanup(t *testing.T) {
10251025
Pod: nil, // a failed POD create request will cause a nil Pod
10261026
Services: []api.Service{{ObjectMeta: objectMeta}},
10271027
ClientFunc: func(t *testing.T, req *http.Request) (*http.Response, error) {
1028-
switch p, m := req.URL.Path, req.Method; {
1029-
default:
1030-
return nil, fmt.Errorf("unexpected request. method: %s, path: %s", m, p)
1031-
}
1028+
p, m := req.URL.Path, req.Method
1029+
return nil, fmt.Errorf("unexpected request. method: %s, path: %s", m, p)
10321030
},
10331031
Error: false,
10341032
},

executors/kubernetes/terminal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (s *executor) getTerminalSettings() (*terminal.TerminalSettings, error) {
5151
wsURL := s.getTerminalWebSocketURL()
5252

5353
caCert := ""
54-
if len(config.CAFile) > 0 {
54+
if config.CAFile != "" {
5555
buf, err := os.ReadFile(config.CAFile)
5656
if err != nil {
5757
return nil, err

executors/kubernetes/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func getKubeClientConfig(
4848
config *common.KubernetesConfig,
4949
overwrites *overwrites,
5050
) (kubeConfig *restclient.Config, err error) {
51-
if len(config.Host) > 0 {
51+
if config.Host != "" {
5252
kubeConfig, err = getOutClusterClientConfig(config)
5353
} else {
5454
kubeConfig, err = guessClientConfig()

helpers/container/services/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func SplitNameAndVersion(serviceDescription string) Service {
4545
service := Service{}
4646
service.Service = registry + imageName
4747

48-
if len(imageVersion) > 0 {
48+
if imageVersion != "" {
4949
service.ImageName = serviceDescription
5050
service.Version = imageVersion
5151
} else {

helpers/parallels/control.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func GetDefaultSnapshot(vmName string) (string, error) {
121121
if pos >= 0 {
122122
snapshot := line[pos+2:]
123123
snapshot = strings.TrimSpace(snapshot)
124-
if len(snapshot) > 0 { // It uses UUID so it should be 38
124+
if snapshot != "" { // It uses UUID so it should be 38
125125
return snapshot, nil
126126
}
127127
}

helpers/vault/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ var (
7272
}
7373
)
7474

75-
func NewClient(URL string, namespace string) (Client, error) {
75+
func NewClient(apiURL string, namespace string) (Client, error) {
7676
config := &api.Config{
77-
Address: URL,
77+
Address: apiURL,
7878
}
7979

8080
client, err := newAPIClient(config)

network/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (n *client) getLastUpdate() string {
8484
}
8585

8686
func (n *client) setLastUpdate(headers http.Header) {
87-
if lu := headers.Get("X-GitLab-Last-Update"); len(lu) > 0 {
87+
if lu := headers.Get("X-GitLab-Last-Update"); lu != "" {
8888
n.lastUpdate = lu
8989
}
9090
}

network/gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ func checkTestArtifactsUploadHandlerContent(w http.ResponseWriter, r *http.Reque
22962296

22972297
w.Header().Set(ContentType, "application/json")
22982298

2299-
if len(testCase.formValueKey) > 0 {
2299+
if testCase.formValueKey != "" {
23002300
if r.FormValue(testCase.formValueKey) != body {
23012301
return
23022302
}

0 commit comments

Comments
 (0)