Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Jun 4, 2024
1 parent 0b823bd commit 3936e44
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 35 deletions.
48 changes: 22 additions & 26 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
linters-settings:
depguard:
list-type: blacklist
packages:
- github.com/jenkins-x/jx/v2/pkg/log/
- github.com/satori/go.uuid
- github.com/pborman/uuid
packages-with-error-message:
- github.com/jenkins-x/jx/v2/pkg/log/: "use jenkins-x/jx-logging instead"
- github.com/satori/go.uuid: "use github.com/google/uuid instead"
- github.com/pborman/uuid: "use github.com/google/uuid instead"
rules:
# Name of a rule.
Main:
list-mode: lax
deny:
- pkg: github.com/jenkins-x/jx/v2/pkg/log/
desc: "use jenkins-x/jx-logging instead"
- pkg: github.com/satori/go.uuid
desc: "use github.com/google/uuid instead"
- pkg: github.com/pborman/uuid
desc: "use github.com/google/uuid instead"
dupl:
threshold: 100
exhaustive:
Expand Down Expand Up @@ -37,17 +39,14 @@ linters-settings:
gocyclo:
min-complexity: 15
goimports: {}
golint:
min-confidence: 0
revive:
confidence: 0
gofmt:
simplify: true
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
govet:
check-shadowing: true
settings:
printf:
funcs:
Expand All @@ -58,11 +57,8 @@ linters-settings:
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell: {}
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand Down Expand Up @@ -102,17 +98,17 @@ issues:
- linters:
- gocritic
text: "unnecessaryDefer:"
- path: scm/driver/ # The drivers mostly implement interfaces and often the methods don't need all parameters
text: "unused-parameter"
linters:
- revive
exclude:
- 'shadow: declaration of "err" shadows declaration at'
max-same-issues: 0
exclude-dirs:
- cmd/docs

run:
timeout: 30m
skip-dirs:
- cmd/docs
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.42.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
4 changes: 2 additions & 2 deletions scm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ package scm
import (
"context"
"errors"

"io"
"net/http"

"net/url"
"strconv"
"strings"
Expand Down Expand Up @@ -182,6 +180,8 @@ func (c *Client) Do(ctx context.Context, in *Request) (*Response, error) {
if client == nil {
client = http.DefaultClient
}
// The callers of this method should do the closing
//nolint:bodyclose
res, err := client.Do(req)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion scm/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (a Action) String() (s string) {
case ActionCompleted:
return "completed"
default:
return
return ""
}
}

Expand Down
3 changes: 1 addition & 2 deletions scm/driver/azure/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ func getIssueCommentAction(src *issueCommentPullRequestHook) scm.Action {
return scm.ActionDelete
} else if src.Resource.Comment.PublishedDate.Equal(src.Resource.Comment.LastUpdatedDate) {
return scm.ActionCreate
} else {
return scm.ActionEdited
}
return scm.ActionEdited
}

func convertPushHook(src *pushHook) *scm.PushHook {
Expand Down
2 changes: 1 addition & 1 deletion scm/driver/fake/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func (s *repositoryService) ListHooks(ctx context.Context, fullName string, opts
}

func (s *repositoryService) CreateHook(ctx context.Context, fullName string, input *scm.HookInput) (*scm.Hook, *scm.Response, error) {
/* #nosec */
hook := &scm.Hook{
//nolint:gosec
ID: fmt.Sprintf("%d", rand.Int()),
Name: input.Name,
Target: input.Target,
Expand Down
2 changes: 1 addition & 1 deletion scm/driver/gitea/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,6 @@ func convertAction(src string) (action scm.Action) {
case "reviewed":
return scm.ActionSubmitted
default:
return
return 0
}
}
2 changes: 1 addition & 1 deletion scm/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ func ExamplePullRequest_merge() {
func ExampleWebhook() {
client := github.NewDefault()

secret := func(webhook scm.Webhook) (string, error) {
secret := func(_ scm.Webhook) (string, error) {
return "topsecret", nil
}

Expand Down
2 changes: 1 addition & 1 deletion scm/transport/oauth2/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ type mockErrorSource struct {
err error
}

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

0 comments on commit 3936e44

Please sign in to comment.