Skip to content

Commit

Permalink
feat: replace golint with revive
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn committed May 24, 2021
1 parent 2347912 commit 0ff6243
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
34 changes: 29 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ linters-settings:
- octalLiteral
gocyclo:
min-complexity: 15
golint:
min-confidence: 0
govet:
check-shadowing: true
maligned:
Expand All @@ -23,7 +21,34 @@ linters-settings:
rules:
json: camel
yaml: camel

revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
Expand All @@ -44,7 +69,6 @@ linters:
- godot # Check if comments end in a period [fast: true, auto-fix: true]
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true]
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: false, auto-fix: false]
- gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
- gosec # Inspects source code for security problems [fast: false, auto-fix: false]
Expand All @@ -55,6 +79,7 @@ linters:
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
- staticcheck #megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
- structcheck # Finds unused struct fields [fast: false, auto-fix: false]
Expand Down Expand Up @@ -99,7 +124,6 @@ linters:
# - prealloc # Finds slice declarations that could potentially be preallocated [fast: true, auto-fix: false]
# - predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
# - promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
# - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
# - scopelint # Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
# - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
# - testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
Expand Down
4 changes: 2 additions & 2 deletions opsmngr/opsmngr.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body int
}
}

req, err := http.NewRequest(method, u.String(), buf)
req, err := http.NewRequestWithContext(ctx, method, u.String(), buf)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (c *Client) NewGZipRequest(ctx context.Context, method, urlStr string) (*ht

u := c.BaseURL.ResolveReference(rel)

req, err := http.NewRequest(method, u.String(), nil)
req, err := http.NewRequestWithContext(ctx, method, u.String(), nil)
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions opsmngr/performance_advisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func (s *PerformanceAdvisorServiceOp) GetSuggestedIndexes(ctx context.Context, g
}

path := fmt.Sprintf(performanceAdvisorSuggestedIndexesLogsPath, groupID, processName)
path, err := setQueryParams(path, opts)
if err != nil {
return nil, nil, err
}

req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
Expand Down

0 comments on commit 0ff6243

Please sign in to comment.