Skip to content

Commit f11061b

Browse files
committed
fix: linting
related to jenkins-x/jx#8670
1 parent 0b823bd commit f11061b

File tree

8 files changed

+29
-35
lines changed

8 files changed

+29
-35
lines changed

.golangci.yml

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
linters-settings:
22
depguard:
3-
list-type: blacklist
4-
packages:
5-
- github.com/jenkins-x/jx/v2/pkg/log/
6-
- github.com/satori/go.uuid
7-
- github.com/pborman/uuid
8-
packages-with-error-message:
9-
- github.com/jenkins-x/jx/v2/pkg/log/: "use jenkins-x/jx-logging instead"
10-
- github.com/satori/go.uuid: "use github.com/google/uuid instead"
11-
- github.com/pborman/uuid: "use github.com/google/uuid instead"
3+
rules:
4+
# Name of a rule.
5+
Main:
6+
list-mode: lax
7+
deny:
8+
- pkg: github.com/jenkins-x/jx/v2/pkg/log/
9+
desc: "use jenkins-x/jx-logging instead"
10+
- pkg: github.com/satori/go.uuid
11+
desc: "use github.com/google/uuid instead"
12+
- pkg: github.com/pborman/uuid
13+
desc: "use github.com/google/uuid instead"
1214
dupl:
1315
threshold: 100
1416
exhaustive:
@@ -37,17 +39,14 @@ linters-settings:
3739
gocyclo:
3840
min-complexity: 15
3941
goimports: {}
40-
golint:
41-
min-confidence: 0
42+
revive:
43+
confidence: 0
4244
gofmt:
4345
simplify: true
44-
gomnd:
45-
settings:
46-
mnd:
47-
# don't include the "operation" and "assign"
48-
checks: [argument, case, condition, return]
46+
mnd:
47+
# don't include the "operation" and "assign"
48+
checks: [argument, case, condition, return]
4949
govet:
50-
check-shadowing: true
5150
settings:
5251
printf:
5352
funcs:
@@ -58,11 +57,8 @@ linters-settings:
5857
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Fatalf
5958
lll:
6059
line-length: 140
61-
maligned:
62-
suggest-new: true
6360
misspell: {}
6461
nolintlint:
65-
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
6662
allow-unused: false # report any unused nolint directives
6763
require-explanation: false # don't require an explanation for nolint directives
6864
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
@@ -102,17 +98,17 @@ issues:
10298
- linters:
10399
- gocritic
104100
text: "unnecessaryDefer:"
101+
- path: scm/driver/ # The drivers mostly implement interfaces and often the methods don't need all parameters
102+
text: "unused-parameter"
103+
linters:
104+
- revive
105105
exclude:
106106
- 'shadow: declaration of "err" shadows declaration at'
107107
max-same-issues: 0
108+
exclude-dirs:
109+
- cmd/docs
108110

109111
run:
110112
timeout: 30m
111-
skip-dirs:
112-
- cmd/docs
113113
# golangci.com configuration
114114
# https://github.com/golangci/golangci/wiki/Configuration
115-
service:
116-
golangci-lint-version: 1.42.x # use the fixed version to not introduce new linters unexpectedly
117-
prepare:
118-
- echo "here I can run custom commands, but no preparation needed for this repo"

scm/client.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ package scm
77
import (
88
"context"
99
"errors"
10-
1110
"io"
1211
"net/http"
13-
1412
"net/url"
1513
"strconv"
1614
"strings"
@@ -186,6 +184,7 @@ func (c *Client) Do(ctx context.Context, in *Request) (*Response, error) {
186184
if err != nil {
187185
return nil, err
188186
}
187+
defer res.Body.Close()
189188

190189
// dumps the response for debugging purposes.
191190
if c.DumpResponse != nil {

scm/const.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (a Action) String() (s string) {
157157
case ActionCompleted:
158158
return "completed"
159159
default:
160-
return
160+
return ""
161161
}
162162
}
163163

scm/driver/azure/webhook.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ func getIssueCommentAction(src *issueCommentPullRequestHook) scm.Action {
9393
return scm.ActionDelete
9494
} else if src.Resource.Comment.PublishedDate.Equal(src.Resource.Comment.LastUpdatedDate) {
9595
return scm.ActionCreate
96-
} else {
97-
return scm.ActionEdited
9896
}
97+
return scm.ActionEdited
9998
}
10099

101100
func convertPushHook(src *pushHook) *scm.PushHook {

scm/driver/fake/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func (s *repositoryService) ListHooks(ctx context.Context, fullName string, opts
179179
}
180180

181181
func (s *repositoryService) CreateHook(ctx context.Context, fullName string, input *scm.HookInput) (*scm.Hook, *scm.Response, error) {
182-
/* #nosec */
183182
hook := &scm.Hook{
183+
//nolint:gosec
184184
ID: fmt.Sprintf("%d", rand.Int()),
185185
Name: input.Name,
186186
Target: input.Target,

scm/driver/gitea/webhook.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,6 @@ func convertAction(src string) (action scm.Action) {
424424
case "reviewed":
425425
return scm.ActionSubmitted
426426
default:
427-
return
427+
return 0
428428
}
429429
}

scm/example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ func ExamplePullRequest_merge() {
673673
func ExampleWebhook() {
674674
client := github.NewDefault()
675675

676-
secret := func(webhook scm.Webhook) (string, error) {
676+
secret := func(_ scm.Webhook) (string, error) {
677677
return "topsecret", nil
678678
}
679679

scm/transport/oauth2/oauth2_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ type mockErrorSource struct {
108108
err error
109109
}
110110

111-
func (s mockErrorSource) Token(ctx context.Context) (*scm.Token, error) {
111+
func (s mockErrorSource) Token(_ context.Context) (*scm.Token, error) {
112112
return nil, s.err
113113
}

0 commit comments

Comments
 (0)