Skip to content

Commit 7751c71

Browse files
committed
all: fix lint suggestions
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent 09358ba commit 7751c71

22 files changed

+123
-8
lines changed

base_json.go

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (v *ProgressToken) MarshalJSON() ([]byte, error) {
6666
if v.name != "" {
6767
return json.Marshal(v.name)
6868
}
69+
6970
return json.Marshal(v.number)
7071
}
7172

@@ -75,5 +76,6 @@ func (v *ProgressToken) UnmarshalJSON(data []byte) error {
7576
if err := json.Unmarshal(data, &v.number); err == nil {
7677
return nil
7778
}
79+
7880
return json.Unmarshal(data, &v.name)
7981
}

basic_gojay.go

+2
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ var (
646646
// MarshalJSONObject implements gojay.MarshalerJSONObject.
647647
func (v TextEditsMap) MarshalJSONObject(enc *gojay.Encoder) {
648648
for key, value := range v {
649+
value := value
649650
enc.ArrayKeyOmitEmpty(string(key), (*TextEdits)(&value))
650651
}
651652
}
@@ -710,6 +711,7 @@ var (
710711
// MarshalJSONObject implements gojay.MarshalerJSONObject.
711712
func (v ChangeAnnotationsMap) MarshalJSONObject(enc *gojay.Encoder) {
712713
for key, value := range v {
714+
value := value
713715
enc.ObjectKeyOmitEmpty(string(key), &value)
714716
}
715717
}

basic_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,8 @@ func testTextDocumentItem(t *testing.T, marshal marshalFunc, unmarshal unmarshal
24142414
}
24152415

24162416
func TestToLanguageIdentifier(t *testing.T) {
2417+
t.Parallel()
2418+
24172419
tests := []struct {
24182420
name string
24192421
ft string

client.go

+6
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler {
2626
h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error {
2727
if ctx.Err() != nil {
2828
xctx := xcontext.Detach(ctx)
29+
2930
return reply(xctx, nil, ErrRequestCancelled)
3031
}
3132

3233
handled, err := clientDispatch(ctx, client, reply, req)
3334
if handled || err != nil {
3435
return err
3536
}
37+
3638
return handler(ctx, reply, req)
3739
}
3840

@@ -169,6 +171,7 @@ func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequ
169171
if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil {
170172
return nil, err
171173
}
174+
172175
return result, nil
173176
}
174177

@@ -209,6 +212,7 @@ func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams
209212
if err := Call(ctx, c.Conn, MethodWorkspaceApplyEdit, params, &result); err != nil {
210213
return false, err
211214
}
215+
212216
return result, nil
213217
}
214218

@@ -225,6 +229,7 @@ func (c *client) Configuration(ctx context.Context, params *ConfigurationParams)
225229
if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil {
226230
return nil, err
227231
}
232+
228233
return result, nil
229234
}
230235

@@ -240,5 +245,6 @@ func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder
240245
if err := Call(ctx, c.Conn, MethodWorkspaceWorkspaceFolders, nil, &result); err != nil {
241246
return nil, err
242247
}
248+
243249
return result, nil
244250
}

client_gojay.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
)
2020

2121
// clientDispatch implements jsonrpc2.Conn.
22-
//nolint:funlen,gocognit
22+
//nolint:funlen
2323
func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, req jsonrpc2.Request) (handled bool, err error) {
2424
if ctx.Err() != nil {
2525
return true, reply(ctx, nil, ErrRequestCancelled)

client_json.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
// clientDispatch implements jsonrpc2.Handler.
21-
//nolint:gocognit,funlen
21+
//nolint:funlen,cyclop
2222
func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, req jsonrpc2.Request) (handled bool, err error) {
2323
if ctx.Err() != nil {
2424
return true, reply(ctx, nil, ErrRequestCancelled)

deprecated.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// SPDX-FileCopyrightText: Copyright 2021 The Go Language Server Authors
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
14
package protocol
25

36
// ClientCapabilitiesShowDocument alias of ShowDocumentClientCapabilities.

diagnostics_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ func testDiagnostic(t *testing.T, marshal marshalFunc, unmarshal unmarshalFunc)
312312
}
313313

314314
func TestDiagnosticSeverity_String(t *testing.T) {
315+
t.Parallel()
316+
315317
tests := []struct {
316318
name string
317319
d DiagnosticSeverity
@@ -356,6 +358,8 @@ func TestDiagnosticSeverity_String(t *testing.T) {
356358
}
357359

358360
func TestDiagnosticTag_String(t *testing.T) {
361+
t.Parallel()
362+
359363
tests := []struct {
360364
name string
361365
d DiagnosticTag
@@ -443,8 +447,7 @@ func testDiagnosticRelatedInformation(t *testing.T, marshal marshalFunc, unmarsh
443447

444448
got, err := marshal(&tt.field)
445449
if (err != nil) != tt.wantMarshalErr {
446-
t.Error(err)
447-
return
450+
t.Fatal(err)
448451
}
449452

450453
if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr {

general_gojay_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Copyright 2019 The Go Language Server Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style
3-
// license that can be found in the LICENSE file.
1+
// SPDX-FileCopyrightText: Copyright 2019 The Go Language Server Authors
2+
// SPDX-License-Identifier: BSD-3-Clause
43

54
//go:build gojay
65
// +build gojay

general_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,8 @@ func testDocumentColorRegistrationOptions(t *testing.T, marshal marshalFunc, unm
34163416
}
34173417

34183418
func TestPrepareSupportDefaultBehavior_String(t *testing.T) {
3419+
t.Parallel()
3420+
34193421
tests := []struct {
34203422
name string
34213423
k PrepareSupportDefaultBehavior
@@ -4215,6 +4217,8 @@ func testShowDocumentResult(t *testing.T, marshal marshalFunc, unmarshal unmarsh
42154217
}
42164218

42174219
func TestTextDocumentSyncKind_String(t *testing.T) {
4220+
t.Parallel()
4221+
42184222
tests := []struct {
42194223
name string
42204224
k TextDocumentSyncKind

handler.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result
2626
if ctx.Err() != nil {
2727
notifyCancel(ctx, conn, id)
2828
}
29+
2930
return err
3031
}
3132

handler_json.go

+2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler {
3333
err = ErrRequestCancelled
3434
}
3535
ctx = xcontext.Detach(ctx)
36+
3637
return reply(ctx, resp, err)
3738
}
39+
3840
return handler(ctx, reply, req)
3941
}
4042

language.go

+2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ const (
324324
)
325325

326326
// String implements fmt.Stringer.
327+
//nolint:cyclop
327328
func (k CompletionItemKind) String() string {
328329
switch k {
329330
case CompletionItemKindText:
@@ -729,6 +730,7 @@ const (
729730
)
730731

731732
// String implements fmt.Stringer.
733+
//nolint:cyclop
732734
func (k SymbolKind) String() string {
733735
switch k {
734736
case SymbolKindFile:

language_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ func testCompletionParams(t *testing.T, marshal marshalFunc, unmarshal unmarshal
139139
}
140140

141141
func TestCompletionTriggerKind_String(t *testing.T) {
142+
t.Parallel()
143+
142144
tests := []struct {
143145
name string
144146
k CompletionTriggerKind
@@ -392,6 +394,8 @@ func testCompletionList(t *testing.T, marshal marshalFunc, unmarshal unmarshalFu
392394
}
393395

394396
func TestInsertTextFormat_String(t *testing.T) {
397+
t.Parallel()
398+
395399
tests := []struct {
396400
name string
397401
k InsertTextFormat
@@ -521,6 +525,8 @@ func testInsertReplaceEdit(t *testing.T, marshal marshalFunc, unmarshal unmarsha
521525
}
522526

523527
func TestInsertTextMode_String(t *testing.T) {
528+
t.Parallel()
529+
524530
tests := []struct {
525531
name string
526532
k InsertTextMode
@@ -711,6 +717,8 @@ func testCompletionItem(t *testing.T, marshal marshalFunc, unmarshal unmarshalFu
711717
}
712718

713719
func TestCompletionItemKind_String(t *testing.T) {
720+
t.Parallel()
721+
714722
tests := []struct {
715723
name string
716724
k CompletionItemKind
@@ -860,6 +868,8 @@ func TestCompletionItemKind_String(t *testing.T) {
860868
}
861869

862870
func TestCompletionItemTag_String(t *testing.T) {
871+
t.Parallel()
872+
863873
tests := []struct {
864874
name string
865875
k CompletionItemTag
@@ -1399,6 +1409,8 @@ func testSignatureHelpParams(t *testing.T, marshal marshalFunc, unmarshal unmars
13991409
}
14001410

14011411
func TestSignatureHelpTriggerKind_String(t *testing.T) {
1412+
t.Parallel()
1413+
14021414
tests := []struct {
14031415
name string
14041416
k SignatureHelpTriggerKind
@@ -2138,6 +2150,8 @@ func testDocumentHighlight(t *testing.T, marshal marshalFunc, unmarshal unmarsha
21382150
}
21392151

21402152
func TestDocumentHighlightKind_String(t *testing.T) {
2153+
t.Parallel()
2154+
21412155
tests := []struct {
21422156
name string
21432157
k DocumentHighlightKind
@@ -2291,6 +2305,8 @@ func testDocumentSymbolParams(t *testing.T, marshal marshalFunc, unmarshal unmar
22912305
}
22922306

22932307
func TestSymbolKind_String(t *testing.T) {
2308+
t.Parallel()
2309+
22942310
tests := []struct {
22952311
name string
22962312
k SymbolKind
@@ -2445,6 +2461,8 @@ func TestSymbolKind_String(t *testing.T) {
24452461
}
24462462

24472463
func TestSymbolTag_String(t *testing.T) {
2464+
t.Parallel()
2465+
24482466
tests := []struct {
24492467
name string
24502468
k SymbolTag
@@ -2925,6 +2943,8 @@ func testCodeActionParams(t *testing.T, marshal marshalFunc, unmarshal unmarshal
29252943
}
29262944

29272945
func TestCodeActionKind_String(t *testing.T) {
2946+
t.Parallel()
2947+
29282948
tests := []struct {
29292949
name string
29302950
k CodeActionKind
@@ -5592,6 +5612,8 @@ func testFoldingRangeParams(t *testing.T, marshal marshalFunc, unmarshal unmarsh
55925612
}
55935613

55945614
func TestFoldingRangeKind_String(t *testing.T) {
5615+
t.Parallel()
5616+
55955617
tests := []struct {
55965618
name string
55975619
s FoldingRangeKind

log.go

+6
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ func (s *loggingStream) Read(ctx context.Context) (jsonrpc2.Message, int64, erro
3535
if err == nil {
3636
s.logCommon(msg, true)
3737
}
38+
3839
return msg, count, err
3940
}
4041

4142
// Write implements jsonrpc2.Stream.Write.
4243
func (s *loggingStream) Write(ctx context.Context, msg jsonrpc2.Message) (int64, error) {
4344
s.logCommon(msg, false)
4445
count, err := s.stream.Write(ctx, msg)
46+
4547
return count, err
4648
}
4749

@@ -75,6 +77,7 @@ func (m *mapped) client(id string) req {
7577
v := m.clientCalls[id]
7678
delete(m.clientCalls, id)
7779
m.mu.Unlock()
80+
7881
return v
7982
}
8083

@@ -83,6 +86,7 @@ func (m *mapped) server(id string) req {
8386
v := m.serverCalls[id]
8487
delete(m.serverCalls, id)
8588
m.mu.Unlock()
89+
8690
return v
8791
}
8892

@@ -135,8 +139,10 @@ func (s *loggingStream) logCommon(msg jsonrpc2.Message, isRead bool) {
135139
id := fmt.Sprint(msg.ID())
136140
if err := msg.Err(); err != nil {
137141
fmt.Fprintf(s.log, "[Error - %s] %s #%s %s%s", pastTense, tmfmt, id, err, eor)
142+
138143
return
139144
}
145+
140146
cc := get(id)
141147
elapsed := tm.Sub(cc.start)
142148
fmt.Fprintf(&buf, "%s response '%s - (%s)' in %dms.\n",

selectionrange.go

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (v EnableSelectionRange) Value() interface{} {
3030
// NewEnableSelectionRange returns the new EnableSelectionRange underlying types SelectionRangeProviderOptions.
3131
func NewEnableSelectionRange(enable bool) SelectionRangeProviderOptions {
3232
v := EnableSelectionRange(enable)
33+
3334
return &v
3435
}
3536

@@ -53,6 +54,7 @@ func NewSelectionRangeOptions(enableWorkDoneProgress bool) SelectionRangeProvide
5354
WorkDoneProgress: enableWorkDoneProgress,
5455
},
5556
}
57+
5658
return &v
5759
}
5860

@@ -86,6 +88,7 @@ func NewSelectionRangeRegistrationOptions(enableWorkDoneProgress bool, selector
8688
ID: id,
8789
},
8890
}
91+
8992
return &v
9093
}
9194

0 commit comments

Comments
 (0)