Skip to content

Commit cc97cea

Browse files
committed
chore: update golangci-lint configuration and bump version to v2.4.0
- Updated .golangci.yml to new format and settings, including enabling specific linters and adjusting exclusions. - Bumped golangci-lint version in Makefile from v1.62.2 to v2.4.0. (REQUIRED by the v9 of the ci-lint action) - Fixed fieldalignment issues in structs
1 parent 2b112e1 commit cc97cea

File tree

5 files changed

+118
-147
lines changed

5 files changed

+118
-147
lines changed

.golangci.yml

Lines changed: 94 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,97 @@
1-
linters-settings:
2-
gocritic:
3-
enabled-tags:
4-
- diagnostic
5-
- experimental
6-
- opinionated
7-
- performance
8-
- style
9-
disabled-checks:
10-
- octalLiteral
11-
gocyclo:
12-
min-complexity: 15
13-
revive:
14-
# see https://github.com/mgechev/revive#available-rules for details.
15-
ignore-generated-header: true
16-
severity: warning
17-
rules:
18-
- name: blank-imports
19-
- name: context-as-argument
20-
- name: context-keys-type
21-
- name: dot-imports
22-
- name: error-return
23-
- name: error-strings
24-
- name: error-naming
25-
- name: errorf
26-
- name: exported
27-
- name: indent-error-flow
28-
- name: if-return
29-
- name: increment-decrement
30-
- name: var-naming
31-
- name: var-declaration
32-
- name: package-comments
33-
- name: range
34-
- name: receiver-naming
35-
- name: time-naming
36-
- name: unexported-return
37-
- name: indent-error-flow
38-
- name: errorf
39-
- name: empty-block
40-
- name: superfluous-else
41-
- name: struct-tag
42-
- name: unused-parameter
43-
- name: unused-receiver
44-
- name: unreachable-code
45-
- name: redefines-builtin-id
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
4+
tests: true
465
linters:
47-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
48-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
49-
disable-all: true
6+
default: none
507
enable:
51-
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
52-
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
53-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
54-
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
55-
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
56-
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
57-
- gocritic # Provides many diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
58-
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
59-
- godot # Check if comments end in a period [fast: true, auto-fix: true]
60-
- 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]
61-
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true]
62-
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
63-
- gosec # Inspects source code for security problems [fast: false, auto-fix: false]
64-
- gosimple # Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
65-
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
66-
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
67-
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
68-
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
69-
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
70-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
71-
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
72-
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
73-
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
74-
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
75-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
76-
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
77-
- unparam # Reports unused function parameters [fast: false, auto-fix: false]
78-
- unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
79-
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
8+
- bodyclose
9+
- dogsled
10+
- errcheck
11+
- errorlint
12+
- exhaustive
13+
- gochecknoinits
14+
- gocritic
15+
- gocyclo
16+
- godot
17+
- goprintffuncname
18+
- gosec
19+
- govet
20+
- ineffassign
21+
- misspell
22+
- nakedret
23+
- nolintlint
24+
- revive
25+
- rowserrcheck
26+
- staticcheck
27+
- thelper
28+
- unconvert
29+
- unparam
30+
- unused
31+
- whitespace
8032

81-
# don't enable:
82-
# - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
83-
# - cyclop # checks function and package cyclomatic complexity [fast: false, auto-fix: false]
84-
# - deadcode # Finds unused code [fast: false, auto-fix: false]
85-
# - dupl # Tool for code clone detection [fast: true, auto-fix: false]
86-
# - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
87-
# - exhaustivestruct # Checks if all struct's fields are initialized [fast: false, auto-fix: false]
88-
# - forbidigo # Forbids identifiers [fast: true, auto-fix: false]
89-
# - forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
90-
# - funlen # Tool for detection of long functions [fast: true, auto-fix: false]
91-
# - gci # Gci control golang package import order and make it always deterministic. [fast: true, auto-fix: true]
92-
# - gochecknoglobals # check that no global variables exist [fast: true, auto-fix: false]
93-
# - gocognit # Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false]
94-
# - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
95-
# - godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
96-
# - gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
97-
# - goerr113 # Golang linter to check the errors handling expressions [fast: false, auto-fix: false]
98-
# - gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
99-
# - goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]
100-
# - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false]
101-
# - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false]
102-
# - importas # Enforces consistent import aliases [fast: false, auto-fix: false]
103-
# - interfacer # Linter that suggests narrower interface types [fast: false, auto-fix: false]
104-
# - lll # Reports long lines [fast: true, auto-fix: false]
105-
# - makezero # Finds slice declarations with non-zero initial length [fast: false, auto-fix: false]
106-
# - maligned # Tool to detect Go structs that would take less memory if their fields were sorted [fast: false, auto-fix: false]
107-
# - nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
108-
# - nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false]
109-
# - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false]
110-
# - noctx # noctx finds sending http request without context.Context [fast: false, auto-fix: false]
111-
# - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test [fast: true, auto-fix: false]
112-
# - prealloc # Finds slice declarations that could potentially be preallocated [fast: true, auto-fix: false]
113-
# - predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
114-
# - promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
115-
# - scopelint # Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
116-
# - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
117-
# - structcheck # Finds unused struct fields [fast: false, auto-fix: false]
118-
# - testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
119-
# - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
120-
# - wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false]
121-
# - wrapcheck # Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false]
122-
# - wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
123-
# - varcheck # Finds unused global variables and constants [fast: false, auto-fix: false]
124-
# - ifshort # Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false]
33+
settings:
34+
gocritic:
35+
enabled-tags:
36+
- diagnostic
37+
- experimental
38+
- opinionated
39+
- performance
40+
- style
41+
disabled-checks:
42+
- octalLiteral
43+
gocyclo:
44+
min-complexity: 15
45+
revive:
46+
ignore-generated-header: true
47+
severity: warning
48+
rules:
49+
- name: blank-imports
50+
- name: context-as-argument
51+
- name: context-keys-type
52+
- name: dot-imports
53+
- name: error-return
54+
- name: error-strings
55+
- name: error-naming
56+
- name: errorf
57+
- name: exported
58+
- name: indent-error-flow
59+
- name: if-return
60+
- name: increment-decrement
61+
- name: var-naming
62+
- name: var-declaration
63+
- name: package-comments
64+
- name: range
65+
- name: receiver-naming
66+
- name: time-naming
67+
- name: unexported-return
68+
- name: empty-block
69+
- name: superfluous-else
70+
- name: struct-tag
71+
- name: unused-parameter
72+
- name: unused-receiver
73+
- name: unreachable-code
74+
- name: redefines-builtin-id
75+
govet:
76+
enable-all: true
77+
misspell:
78+
locale: US
79+
exclusions:
80+
generated: lax
81+
presets:
82+
- comments
83+
- common-false-positives
84+
- legacy
85+
- std-error-handling
86+
rules:
87+
- linters:
88+
- govet
89+
text: "fieldalignment: struct with 232 pointer bytes could be 224"
90+
- path: event_triggers\.go
91+
linters:
92+
- govet
93+
text: "fieldalignment:.*EventTriggerConfig"
94+
formatters:
95+
enable:
96+
- gofmt
97+
- goimports

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
22

33
SOURCE_FILES?=./...
4-
GOLANGCI_VERSION=v1.62.2
4+
GOLANGCI_VERSION=v2.4.0
55
COVERAGE=coverage.out
66

77
export PATH := ./bin:$(PATH)

appservices/appservices.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ type (
4949

5050
// Client manages communication with Ops Manager API.
5151
type Client struct {
52-
client *http.Client
53-
BaseURL *url.URL
54-
UserAgent string
52+
client *http.Client
53+
BaseURL *url.URL
54+
Apps AppsService
55+
EventTriggers EventTriggersService
56+
onRequestCompleted RequestCompletionCallback
57+
UserAgent string
5558

5659
// copy raw atlas server response to the Response struct
5760
withRaw bool
58-
59-
Apps AppsService
60-
EventTriggers EventTriggersService
61-
62-
onRequestCompleted RequestCompletionCallback
6361
}
6462

6563
type service struct {

appservices/appservices_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ func TestNew(t *testing.T) {
131131

132132
type testRequestBody struct {
133133
TestName string `json:"testName"`
134-
TestCounter int64 `json:"testCounter"`
135134
TestUserData string `json:"testUserData"`
135+
TestCounter int64 `json:"testCounter"`
136136
}
137137

138138
func TestNewRequest_withUserData(t *testing.T) {

appservices/event_triggers.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,44 +173,44 @@ func (s *EventTriggersServiceOp) Delete(ctx context.Context, groupID, appID, tri
173173

174174
// EventTrigger Represents a response of a trigger.
175175
type EventTrigger struct {
176+
EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
177+
Disabled *bool `json:"disabled,omitempty"`
178+
LastModified *int64 `json:"last_modified,omitempty"`
179+
Config EventTriggerConfig `json:"config,omitempty"`
176180
ID string `json:"_id,omitempty"`
177181
Name string `json:"name,omitempty"`
178182
Type string `json:"type,omitempty"`
179183
FunctionID string `json:"function_id,omitempty"`
180184
FunctionName string `json:"function_name,omitempty"`
181-
Disabled *bool `json:"disabled,omitempty"`
182-
Config EventTriggerConfig `json:"config,omitempty"`
183-
EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
184-
LastModified *int64 `json:"last_modified,omitempty"`
185185
}
186186

187187
// EventTriggerRequest Represents a request of create a trigger.
188188
type EventTriggerRequest struct {
189+
Config *EventTriggerConfig `json:"config,omitempty"`
190+
EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
191+
Disabled *bool `json:"disabled,omitempty"`
189192
Name string `json:"name,omitempty"`
190193
Type string `json:"type,omitempty"`
191194
FunctionID string `json:"function_id,omitempty"`
192-
Disabled *bool `json:"disabled,omitempty"`
193-
Config *EventTriggerConfig `json:"config,omitempty"`
194-
EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
195195
}
196196

197197
// EventTriggerConfig Represents a request of a trigger config.
198198
type EventTriggerConfig struct {
199199
OperationTypes []string `json:"operation_types,omitempty"`
200-
OperationType string `json:"operation_type,omitempty"`
201200
Providers []string `json:"providers,omitempty"`
202-
Database string `json:"database,omitempty"`
203-
Collection string `json:"collection,omitempty"`
204-
ServiceID string `json:"service_id,omitempty"`
205-
Match interface{} `json:"match,omitempty"`
206-
Project interface{} `json:"project,omitempty"`
207201
FullDocument *bool `json:"full_document,omitempty"`
208202
FullDocumentBeforeChange *bool `json:"full_document_before_change,omitempty"`
209-
Schedule string `json:"schedule,omitempty"`
210-
ScheduleType string `json:"schedule_type,omitempty"`
211203
Unordered *bool `json:"unordered,omitempty"`
212-
ClusterName string `json:"clusterName,omitempty"`
213204
TolerateResumeErrors *bool `json:"tolerate_resume_errors,omitempty"`
214205
SkipCatchupEvents *bool `json:"skip_catchup_events,omitempty"`
215206
MaximumThroughput *bool `json:"maximum_throughput,omitempty"`
207+
Match interface{} `json:"match,omitempty"`
208+
Project interface{} `json:"project,omitempty"`
209+
OperationType string `json:"operation_type,omitempty"`
210+
Database string `json:"database,omitempty"`
211+
Collection string `json:"collection,omitempty"`
212+
ServiceID string `json:"service_id,omitempty"`
213+
Schedule string `json:"schedule,omitempty"`
214+
ScheduleType string `json:"schedule_type,omitempty"`
215+
ClusterName string `json:"clusterName,omitempty"`
216216
}

0 commit comments

Comments
 (0)