Skip to content

Commit f193005

Browse files
committed
Upgrade golangci-lint, more linters
Introduces new linters, upgrade golangci-lint to version (v1.63.4)
1 parent c01e593 commit f193005

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1254
-802
lines changed

.golangci.yml

+30-17
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,32 @@ linters-settings:
2525
- ^os.Exit$
2626
- ^panic$
2727
- ^print(ln)?$
28+
varnamelen:
29+
max-distance: 12
30+
min-name-length: 2
31+
ignore-type-assert-ok: true
32+
ignore-map-index-ok: true
33+
ignore-chan-recv-ok: true
34+
ignore-decls:
35+
- i int
36+
- n int
37+
- w io.Writer
38+
- r io.Reader
39+
- b []byte
2840

2941
linters:
3042
enable:
3143
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
3244
- bidichk # Checks for dangerous unicode character sequences
3345
- bodyclose # checks whether HTTP response body is closed successfully
46+
- containedctx # containedctx is a linter that detects struct contained context.Context field
3447
- contextcheck # check the function whether use a non-inherited context
48+
- cyclop # checks function and package cyclomatic complexity
3549
- decorder # check declaration order and count of types, constants, variables and functions
3650
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
3751
- dupl # Tool for code clone detection
3852
- durationcheck # check for two durations multiplied together
53+
- err113 # Golang linter to check the errors handling expressions
3954
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
4055
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
4156
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
@@ -46,66 +61,64 @@ linters:
4661
- forcetypeassert # finds forced type assertions
4762
- gci # Gci control golang package import order and make it always deterministic.
4863
- gochecknoglobals # Checks that no globals are present in Go code
49-
- gochecknoinits # Checks that no init functions are present in Go code
5064
- gocognit # Computes and checks the cognitive complexity of functions
5165
- goconst # Finds repeated strings that could be replaced by a constant
5266
- gocritic # The most opinionated Go source code linter
67+
- gocyclo # Computes and checks the cyclomatic complexity of functions
68+
- godot # Check if comments end in a period
5369
- godox # Tool for detection of FIXME, TODO and other comment keywords
54-
- err113 # Golang linter to check the errors handling expressions
5570
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
5671
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
5772
- goheader # Checks is file header matches to pattern
5873
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
5974
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
60-
- 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.
6175
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
6276
- gosec # Inspects source code for security problems
6377
- gosimple # Linter for Go source code that specializes in simplifying a code
6478
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
6579
- grouper # An analyzer to analyze expression groups.
6680
- importas # Enforces consistent import aliases
6781
- ineffassign # Detects when assignments to existing variables are not used
82+
- lll # Reports long lines
83+
- maintidx # maintidx measures the maintainability index of each function.
84+
- makezero # Finds slice declarations with non-zero initial length
6885
- misspell # Finds commonly misspelled English words in comments
86+
- nakedret # Finds naked returns in functions greater than a specified function length
87+
- nestif # Reports deeply nested if statements
6988
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
7089
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
90+
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
7191
- noctx # noctx finds sending http request without context.Context
7292
- predeclared # find code that shadows one of Go's predeclared identifiers
7393
- revive # golint replacement, finds style mistakes
7494
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
7595
- stylecheck # Stylecheck is a replacement for golint
7696
- tagliatelle # Checks the struct tags.
7797
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
78-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
98+
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
7999
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
80100
- unconvert # Remove unnecessary type conversions
81101
- unparam # Reports unused function parameters
82102
- unused # Checks Go code for unused constants, variables, functions and types
103+
- varnamelen # checks that the length of a variable's name matches its scope
83104
- wastedassign # wastedassign finds wasted assignment statements
84105
- whitespace # Tool for detection of leading and trailing whitespace
85106
disable:
86107
- depguard # Go linter that checks if package imports are in a list of acceptable packages
87-
- containedctx # containedctx is a linter that detects struct contained context.Context field
88-
- cyclop # checks function and package cyclomatic complexity
89108
- funlen # Tool for detection of long functions
90-
- gocyclo # Computes and checks the cyclomatic complexity of functions
91-
- godot # Check if comments end in a period
92-
- gomnd # An analyzer to detect magic numbers.
109+
- gochecknoinits # Checks that no init functions are present in Go code
110+
- 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.
111+
- interfacebloat # A linter that checks length of interface.
93112
- ireturn # Accept Interfaces, Return Concrete Types
94-
- lll # Reports long lines
95-
- maintidx # maintidx measures the maintainability index of each function.
96-
- makezero # Finds slice declarations with non-zero initial length
97-
- nakedret # Finds naked returns in functions greater than a specified function length
98-
- nestif # Reports deeply nested if statements
99-
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
113+
- mnd # An analyzer to detect magic numbers
100114
- nolintlint # Reports ill-formed or insufficient nolint directives
101115
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
102116
- prealloc # Finds slice declarations that could potentially be preallocated
103117
- promlinter # Check Prometheus metrics naming via promlint
104118
- rowserrcheck # checks whether Err of rows is checked successfully
105119
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
106120
- testpackage # linter that makes you use a separate _test package
107-
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
108-
- varnamelen # checks that the length of a variable's name matches its scope
121+
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
109122
- wrapcheck # Checks that errors returned from external packages are wrapped
110123
- wsl # Whitespace Linter - Forces you to use empty lines!
111124

ack_timer.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
ackTimerClosed
2727
)
2828

29-
// ackTimer provides the retnransmission timer conforms with RFC 4960 Sec 6.3.1
29+
// ackTimer provides the retnransmission timer conforms with RFC 4960 Sec 6.3.1.
3030
type ackTimer struct {
3131
timer *time.Timer
3232
observer ackTimerObserver
@@ -40,6 +40,7 @@ func newAckTimer(observer ackTimerObserver) *ackTimer {
4040
t := &ackTimer{observer: observer}
4141
t.timer = time.AfterFunc(math.MaxInt64, t.timeout)
4242
t.timer.Stop()
43+
4344
return t
4445
}
4546

@@ -65,11 +66,12 @@ func (t *ackTimer) start() bool {
6566
t.state = ackTimerStarted
6667
t.pending++
6768
t.timer.Reset(ackInterval)
69+
6870
return true
6971
}
7072

7173
// stops the timer. this is similar to stop() but subsequent start() call
72-
// will fail (the timer is no longer usable)
74+
// will fail (the timer is no longer usable).
7375
func (t *ackTimer) stop() {
7476
t.mutex.Lock()
7577
defer t.mutex.Unlock()
@@ -83,7 +85,7 @@ func (t *ackTimer) stop() {
8385
}
8486

8587
// closes the timer. this is similar to stop() but subsequent start() call
86-
// will fail (the timer is no longer usable)
88+
// will fail (the timer is no longer usable).
8789
func (t *ackTimer) close() {
8890
t.mutex.Lock()
8991
defer t.mutex.Unlock()
@@ -95,7 +97,7 @@ func (t *ackTimer) close() {
9597
}
9698

9799
// isRunning tests if the timer is running.
98-
// Debug purpose only
100+
// Debug purpose only.
99101
func (t *ackTimer) isRunning() bool {
100102
t.mutex.Lock()
101103
defer t.mutex.Unlock()

0 commit comments

Comments
 (0)