Skip to content

Commit f564527

Browse files
committed
all: fix lint suggestions
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent 406bb8e commit f564527

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.golangci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ run:
55
skip-dirs: []
66
skip-dirs-use-default: true
77
skip-files: []
8-
allow-parallel-runners: false
8+
allow-parallel-runners: true
99

1010
output:
1111
format: colored-line-number
@@ -17,10 +17,10 @@ output:
1717
linters-settings:
1818
dupl:
1919
threshold: 100
20-
errcheck:
21-
check-type-assertions: true
22-
check-blank: true
23-
exclude: .errcheckignore
20+
# errcheck:
21+
# check-type-assertions: true
22+
# check-blank: true
23+
# exclude: .errcheckignore
2424
funlen:
2525
lines: 100
2626
statements: 60
@@ -54,7 +54,7 @@ linters-settings:
5454
gofmt:
5555
simplify: true
5656
goimports:
57-
local-prefixes: go.lsp.dev/jsonrpc2,go.lsp.dev
57+
local-prefixes: go.lsp.dev/jsonrpc2
5858
golint:
5959
min-confidence: 0.3
6060
govet:
@@ -96,6 +96,8 @@ linters-settings:
9696
linters:
9797
fast: false
9898
disabled:
99+
- deadcode # Finds unused code
100+
- errcheck # Errcheck is a program for checking for unchecked errors in go programs
99101
- exhaustivestruct # Checks if all struct's fields are initialized
100102
- forbidigo # Forbids identifiers
101103
- gci # Gci control golang package import order and make it always deterministic
@@ -105,23 +107,23 @@ linters:
105107
- goerr113 # Golang linter to check the errors handling expressions
106108
- gofumpt # Gofumpt checks whether code was gofumpt-ed
107109
- goheader # Checks is file header matches to pattern
110+
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
108111
- gomnd # An analyzer to detect magic numbers
109112
- gomodguard # Allow and block list linter for direct Go module dependencies
110113
- gosec # Inspects source code for security problems
111114
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
112115
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
113116
- scopelint # Scopelint checks for unpinned variables in go programs
114117
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed
118+
- unparam # Reports unused function parameters
115119
- wrapcheck # Checks that errors returned from external packages are wrapped TODO(zchee): enable
116120
- wsl # Whitespace Linter
117121
enable:
118122
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
119123
- bodyclose # checks whether HTTP response body is closed successfully
120-
- deadcode # Finds unused code
121124
- depguard # Go linter that checks if package imports are in a list of acceptable packages
122125
- dogsled # Checks assignments with too many blank identifiers
123126
- dupl # Tool for code clone detection
124-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs
125127
- errorlint # source code linter for Go software that can be used to find code that will cause problemswith the error wrapping scheme introduced in Go 1.13
126128
- exhaustive # check exhaustiveness of enum switch statements
127129
- exportloopref # checks for pointers to enclosing loop variables
@@ -133,7 +135,6 @@ linters:
133135
- godot # Check if comments end in a period
134136
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
135137
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
136-
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
137138
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
138139
- gosimple # Linter for Go source code that specializes in simplifying a code
139140
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
@@ -157,7 +158,6 @@ linters:
157158
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
158159
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
159160
- unconvert # Remove unnecessary type conversions
160-
- unparam # Reports unused function parameters
161161
- unused # Checks Go code for unused constants, variables, functions and types
162162
- varcheck # Finds unused global variables and constants
163163
- whitespace # Tool for detection of leading and trailing whitespace

conn.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (c *conn) Notify(ctx context.Context, method string, params interface{}) (e
151151
return err
152152
}
153153

154-
func (c *conn) replier(req Message, spanDone func()) Replier {
154+
func (c *conn) replier(req Message) Replier {
155155
return func(ctx context.Context, result interface{}, err error) error {
156156
call, ok := req.(*Call)
157157
if !ok {
@@ -173,9 +173,9 @@ func (c *conn) replier(req Message, spanDone func()) Replier {
173173
}
174174
}
175175

176-
func (c *conn) write(ctx context.Context, msg Message) (n int64, err error) {
176+
func (c *conn) write(ctx context.Context, msg Message) (int64, error) {
177177
c.writeMu.Lock()
178-
n, err = c.stream.Write(ctx, msg)
178+
n, err := c.stream.Write(ctx, msg)
179179
c.writeMu.Unlock()
180180
if err != nil {
181181
return 0, fmt.Errorf("write to stream: %w", err)
@@ -203,7 +203,9 @@ func (c *conn) run(ctx context.Context, handler Handler) {
203203

204204
switch msg := msg.(type) {
205205
case Request:
206-
handler(ctx, c.replier(msg, func() {}), msg)
206+
if err := handler(ctx, c.replier(msg), msg); err != nil {
207+
c.fail(err)
208+
}
207209

208210
case *Response:
209211
// If method is not set, this should be a response, in which case we must

handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func AsyncHandler(handler Handler) (h Handler) {
111111

112112
go func() {
113113
<-waitForPrevious
114-
handler(ctx, reply, req)
114+
_ = handler(ctx, reply, req)
115115
}()
116116
return nil
117117
})

0 commit comments

Comments
 (0)