Skip to content

Commit dd685d4

Browse files
committed
all: fix lint issues
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 32a3f72 commit dd685d4

15 files changed

+61
-84
lines changed

.golangci.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ linters:
3131
- cyclop # checks function and package cyclomatic complexity
3232
- decorder # check declaration order and count of types, constants, variables and functions
3333
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
34-
- dupl # Tool for code clone detection
3534
- dupword # checks for duplicate words in the source code
3635
- durationcheck # check for two durations multiplied together
37-
- errcheck # errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases
3836
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
3937
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
4038
- 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.
@@ -44,7 +42,6 @@ linters:
4442
- ginkgolinter # enforces standards of using ginkgo and gomega
4543
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid
4644
- gocognit # Computes and checks the cognitive complexity of functions
47-
- goconst # Finds repeated strings that could be replaced by a constant
4845
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
4946
- gocyclo # Computes and checks the cyclomatic complexity of functions
5047
- godot # Check if comments end in a period
@@ -61,9 +58,7 @@ linters:
6158
- importas # Enforces consistent import aliases
6259
- inamedparam # reports interfaces with unnamed method parameters [fast: true, auto-fix: false]
6360
- ineffassign # Detects when assignments to existing variables are not used
64-
- interfacebloat # A linter that checks the number of methods inside an interface
6561
- intrange # intrange is a linter to find places where for loops could make use of an integer range. [fast: true, auto-fix: false]
66-
- lll # Reports long lines
6762
- loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).
6863
- maintidx # maintidx measures the maintainability index of each function.
6964
- makezero # Finds slice declarations with non-zero initial length
@@ -94,15 +89,13 @@ linters:
9489
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
9590
- testableexamples # linter checks if examples are testable (have an expected output)
9691
- thelper # thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers
97-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
9892
- unconvert # Remove unnecessary type conversions
9993
- unparam # Reports unused function parameters
10094
- unused # Checks Go code for unused constants, variables, functions and types
10195
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library
10296
- varnamelen # checks that the length of a variable's name matches its scope
10397
- wastedassign # wastedassign finds wasted assignment statements.
10498
- whitespace # Tool for detection of leading and trailing whitespace
105-
- wrapcheck # Checks that errors returned from external packages are wrapped
10699
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
107100

108101
linters-settings:
@@ -114,15 +107,6 @@ linters-settings:
114107
max-complexity: 15
115108
# package-average:
116109
skip-tests: true
117-
dupl:
118-
threshold: 150
119-
errcheck:
120-
disable-default-exclusions: false
121-
check-type-assertions: false
122-
check-blank: true
123-
ignore: ""
124-
# exclude: .errcheckignore
125-
exclude-functions: []
126110
errorlint:
127111
errorf: true
128112
asserts: true
@@ -132,9 +116,6 @@ linters-settings:
132116
statements: 60
133117
gocognit:
134118
min-complexity: 30
135-
goconst:
136-
min-len: 3
137-
min-occurrences: 3
138119
gocritic:
139120
enabled-tags:
140121
- diagnostic
@@ -144,6 +125,7 @@ linters-settings:
144125
- style
145126
disabled-checks:
146127
- commentedOutCode
128+
- deprecatedComment
147129
- whyNoLint
148130
settings:
149131
hugeParam:
@@ -177,6 +159,9 @@ linters-settings:
177159
under: 15
178160
misspell:
179161
locale: US
162+
ignore-words:
163+
- cancelled
164+
- cancelling
180165
nakedret:
181166
max-func-lines: 30
182167
nestif:
@@ -204,7 +189,6 @@ linters-settings:
204189
issues:
205190
include:
206191
# include revive rules
207-
- "EXC0012"
208192
- "EXC0013"
209193
- "EXC0014"
210194
- "EXC0015"

base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (v ProgressToken) Format(f fmt.State, r rune) {
7373

7474
// String returns a string representation of the ProgressToken.
7575
func (v ProgressToken) String() string {
76-
return fmt.Sprint(v)
76+
return fmt.Sprint(v) //nolint:gocritic
7777
}
7878

7979
// MarshalJSON implements json.Marshaler.

base_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package protocol
55

66
import (
7-
"fmt"
87
"reflect"
98
"testing"
109

@@ -176,7 +175,7 @@ func TestProgressParams(t *testing.T) {
176175
}
177176

178177
if token := got.Token; !reflect.ValueOf(token).IsZero() {
179-
if diff := cmp.Diff(fmt.Sprint(token), wantWorkDoneToken); (diff != "") != tt.wantErr {
178+
if diff := cmp.Diff(token.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
180179
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
181180
}
182181
}

basic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ type LocationLink struct {
9393
// TargetSelectionRange is the range that should be selected and revealed when this link is being followed,
9494
// e.g the name of a function.
9595
//
96-
// Must be contained by the the TargetRange. See also DocumentSymbol#range
96+
// Must be contained by the TargetRange. See also DocumentSymbol#range
9797
TargetSelectionRange Range `json:"targetSelectionRange"`
9898
}
9999

@@ -346,7 +346,7 @@ const (
346346
// ClojureLanguage Clojure Language.
347347
ClojureLanguage LanguageIdentifier = "clojure"
348348

349-
// CoffeescriptLanguage CoffeeScript Language.
349+
// CoffeeScriptLanguage CoffeeScript Language.
350350
CoffeeScriptLanguage LanguageIdentifier = "coffeescript"
351351

352352
// CLanguage C Language.

callhierarchy_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package protocol
55

66
import (
7-
"fmt"
87
"testing"
98

109
"github.com/google/go-cmp/cmp"
@@ -506,7 +505,7 @@ func TestCallHierarchyPrepareParams(t *testing.T) {
506505
}
507506

508507
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
509-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
508+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
510509
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
511510
}
512511
}
@@ -852,13 +851,13 @@ func TestCallHierarchyIncomingCallsParams(t *testing.T) {
852851
}
853852

854853
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
855-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
854+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
856855
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
857856
}
858857
}
859858

860859
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
861-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
860+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
862861
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
863862
}
864863
}
@@ -1178,13 +1177,13 @@ func TestCallHierarchyOutgoingCallsParams(t *testing.T) {
11781177
}
11791178

11801179
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
1181-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
1180+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
11821181
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
11831182
}
11841183
}
11851184

11861185
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
1187-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
1186+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
11881187
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
11891188
}
11901189
}

errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const (
1313
// @since 3.16.0.
1414
LSPReservedErrorRangeStart jsonrpc2.Code = -32899
1515

16-
// ContentModified is the state change that invalidates the result of a request in execution.
16+
// CodeContentModified is the state change that invalidates the result of a request in execution.
1717
//
1818
// Defined by the protocol.
1919
CodeContentModified jsonrpc2.Code = -32801
2020

21-
// RequestCancelled is the cancellation error.
21+
// CodeRequestCancelled is the cancellation error.
2222
//
2323
// Defined by the protocol.
2424
CodeRequestCancelled jsonrpc2.Code = -32800

general_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package protocol
55

66
import (
7-
"fmt"
87
"path/filepath"
98
"testing"
109

@@ -329,7 +328,7 @@ func TestInitializeParams(t *testing.T) {
329328
}
330329

331330
if token := got.WorkDoneToken; token != nil {
332-
if diff := cmp.Diff(fmt.Sprint(token), wantWorkDoneToken); (diff != "") != tt.wantErr {
331+
if diff := cmp.Diff(token.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
333332
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
334333
}
335334
}
@@ -990,13 +989,13 @@ func TestReferencesParams(t *testing.T) {
990989
}
991990

992991
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
993-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
992+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
994993
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
995994
}
996995
}
997996

998997
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
999-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
998+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
1000999
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
10011000
}
10021001
}
@@ -1259,13 +1258,13 @@ func TestDocumentHighlightParams(t *testing.T) {
12591258
}
12601259

12611260
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
1262-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
1261+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
12631262
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
12641263
}
12651264
}
12661265

12671266
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
1268-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
1267+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
12691268
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
12701269
}
12711270
}
@@ -2129,13 +2128,13 @@ func TestDeclarationParams(t *testing.T) {
21292128
}
21302129

21312130
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
2132-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
2131+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
21332132
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
21342133
}
21352134
}
21362135

21372136
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
2138-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
2137+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
21392138
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
21402139
}
21412140
}
@@ -2398,13 +2397,13 @@ func TestDefinitionParams(t *testing.T) {
23982397
}
23992398

24002399
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
2401-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
2400+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
24022401
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
24032402
}
24042403
}
24052404

24062405
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
2407-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
2406+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
24082407
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
24092408
}
24102409
}
@@ -2807,13 +2806,13 @@ func TestTypeDefinitionParams(t *testing.T) {
28072806
}
28082807

28092808
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
2810-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
2809+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
28112810
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
28122811
}
28132812
}
28142813

28152814
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
2816-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
2815+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
28172816
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
28182817
}
28192818
}
@@ -3202,13 +3201,13 @@ func TestImplementationParams(t *testing.T) {
32023201
}
32033202

32043203
if workDoneToken := got.WorkDoneToken; workDoneToken != nil {
3205-
if diff := cmp.Diff(fmt.Sprint(workDoneToken), wantWorkDoneToken); (diff != "") != tt.wantErr {
3204+
if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr {
32063205
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
32073206
}
32083207
}
32093208

32103209
if partialResultToken := got.PartialResultToken; partialResultToken != nil {
3211-
if diff := cmp.Diff(fmt.Sprint(partialResultToken), wantPartialResultToken); (diff != "") != tt.wantErr {
3210+
if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr {
32123211
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
32133212
}
32143213
}

handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ func notifyCancel(ctx context.Context, conn jsonrpc2.Conn, id jsonrpc2.ID) {
8484
}
8585

8686
func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err error) error {
87-
return reply(ctx, nil, fmt.Errorf("%s: %w", jsonrpc2.ErrParse, err))
87+
return reply(ctx, nil, fmt.Errorf("%w: %w", jsonrpc2.ErrParse, err))
8888
}

language.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ type InsertReplaceEdit struct {
119119
type InsertTextMode float64
120120

121121
const (
122-
// AsIs is the insertion or replace strings is taken as it is. If the
122+
// InsertTextModeAsIs is the insertion or replace strings is taken as it is. If the
123123
// value is multi line the lines below the cursor will be
124124
// inserted using the indentation defined in the string value.
125125
// The client will not apply any kind of adjustments to the
126126
// string.
127127
InsertTextModeAsIs InsertTextMode = 1
128128

129-
// AdjustIndentation is the editor adjusts leading whitespace of new lines so that
129+
// InsertTextModeAdjustIndentation is the editor adjusts leading whitespace of new lines so that
130130
// they match the indentation up to the cursor of the line for
131131
// which the item is accepted.
132132
//

0 commit comments

Comments
 (0)