Skip to content

Commit d0f91d0

Browse files
committed
review: add keys and delete zero values.
1 parent db6956d commit d0f91d0

File tree

1 file changed

+50
-58
lines changed

1 file changed

+50
-58
lines changed

pkg/golinters/nolintlint/nolintlint_test.go

Lines changed: 50 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func foo() {
4040
other() //nolintother
4141
}`,
4242
expected: []issueWithReplacement{
43-
{"directive `//nolint` should provide explanation such as `//nolint // this is why` at testing.go:5:1", nil},
44-
{"directive `//nolint` should provide explanation such as `//nolint // this is why` at testing.go:7:9", nil},
45-
{"directive `//nolint //` should provide explanation such as `//nolint // this is why` at testing.go:8:9", nil},
46-
{"directive `//nolint // ` should provide explanation such as `//nolint // this is why` at testing.go:9:9", nil},
43+
{issue: "directive `//nolint` should provide explanation such as `//nolint // this is why` at testing.go:5:1"},
44+
{issue: "directive `//nolint` should provide explanation such as `//nolint // this is why` at testing.go:7:9"},
45+
{issue: "directive `//nolint //` should provide explanation such as `//nolint // this is why` at testing.go:8:9"},
46+
{issue: "directive `//nolint // ` should provide explanation such as `//nolint // this is why` at testing.go:9:9"},
4747
},
4848
},
4949
{
@@ -57,7 +57,7 @@ package bar
5757
//nolint:dupl
5858
func foo() {}`,
5959
expected: []issueWithReplacement{
60-
{"directive `//nolint:dupl` should provide explanation such as `//nolint:dupl // this is why` at testing.go:6:1", nil},
60+
{issue: "directive `//nolint:dupl` should provide explanation such as `//nolint:dupl // this is why` at testing.go:6:1"},
6161
},
6262
},
6363
{
@@ -83,8 +83,8 @@ func foo() {
8383
bad() // nolint // because
8484
}`,
8585
expected: []issueWithReplacement{
86-
{"directive `//nolint` should mention specific linter such as `//nolint:my-linter` at testing.go:6:9", nil},
87-
{"directive `// nolint // because` should mention specific linter such as `// nolint:my-linter` at testing.go:7:9", nil},
86+
{issue: "directive `//nolint` should mention specific linter such as `//nolint:my-linter` at testing.go:6:9"},
87+
{issue: "directive `// nolint // because` should mention specific linter such as `// nolint:my-linter` at testing.go:7:9"},
8888
},
8989
},
9090
{
@@ -97,18 +97,16 @@ func foo() {
9797
bad() // nolint
9898
good() //nolint
9999
}`,
100-
expected: []issueWithReplacement{
101-
{
102-
"directive `// nolint` should be written without leading space as `//nolint` at testing.go:5:9",
103-
&result.Replacement{
104-
Inline: &result.InlineFix{
105-
StartCol: 10,
106-
Length: 1,
107-
NewString: "",
108-
},
100+
expected: []issueWithReplacement{{
101+
issue: "directive `// nolint` should be written without leading space as `//nolint` at testing.go:5:9",
102+
replacement: &result.Replacement{
103+
Inline: &result.InlineFix{
104+
StartCol: 10,
105+
Length: 1,
106+
NewString: "",
109107
},
110108
},
111-
},
109+
}},
112110
},
113111
{
114112
desc: "extra spaces in front of directive are reported",
@@ -119,18 +117,16 @@ func foo() {
119117
bad() // nolint
120118
good() // nolint
121119
}`,
122-
expected: []issueWithReplacement{
123-
{
124-
"directive `// nolint` should not have more than one leading space at testing.go:5:9",
125-
&result.Replacement{
126-
Inline: &result.InlineFix{
127-
StartCol: 10,
128-
Length: 2,
129-
NewString: " ",
130-
},
120+
expected: []issueWithReplacement{{
121+
issue: "directive `// nolint` should not have more than one leading space at testing.go:5:9",
122+
replacement: &result.Replacement{
123+
Inline: &result.InlineFix{
124+
StartCol: 10,
125+
Length: 2,
126+
NewString: " ",
131127
},
132128
},
133-
},
129+
}},
134130
},
135131
{
136132
desc: "spaces are allowed in comma-separated list of linters",
@@ -144,7 +140,7 @@ func foo() {
144140
good() // nolint: linter1, linter2
145141
}`,
146142
expected: []issueWithReplacement{
147-
{"directive `// nolint:linter1 linter2` should match `// nolint[:<comma-separated-linters>] [// <explanation>]` at testing.go:6:9", nil}, //nolint:lll // this is a string
143+
{issue: "directive `// nolint:linter1 linter2` should match `// nolint[:<comma-separated-linters>] [// <explanation>]` at testing.go:6:9"}, //nolint:lll // this is a string
148144
},
149145
},
150146
{
@@ -166,18 +162,16 @@ package bar
166162
func foo() {
167163
bad() //nolint
168164
}`,
169-
expected: []issueWithReplacement{
170-
{
171-
"directive `//nolint` is unused at testing.go:5:9",
172-
&result.Replacement{
173-
Inline: &result.InlineFix{
174-
StartCol: 8,
175-
Length: 8,
176-
NewString: "",
177-
},
165+
expected: []issueWithReplacement{{
166+
issue: "directive `//nolint` is unused at testing.go:5:9",
167+
replacement: &result.Replacement{
168+
Inline: &result.InlineFix{
169+
StartCol: 8,
170+
Length: 8,
171+
NewString: "",
178172
},
179173
},
180-
},
174+
}},
181175
},
182176
{
183177
desc: "needs unused with one specific linter generates replacement",
@@ -188,18 +182,16 @@ package bar
188182
func foo() {
189183
bad() //nolint:somelinter
190184
}`,
191-
expected: []issueWithReplacement{
192-
{
193-
"directive `//nolint:somelinter` is unused for linter \"somelinter\" at testing.go:5:9",
194-
&result.Replacement{
195-
Inline: &result.InlineFix{
196-
StartCol: 8,
197-
Length: 19,
198-
NewString: "",
199-
},
185+
expected: []issueWithReplacement{{
186+
issue: "directive `//nolint:somelinter` is unused for linter \"somelinter\" at testing.go:5:9",
187+
replacement: &result.Replacement{
188+
Inline: &result.InlineFix{
189+
StartCol: 8,
190+
Length: 19,
191+
NewString: "",
200192
},
201193
},
202-
},
194+
}},
203195
},
204196
{
205197
desc: "needs unused with multiple specific linters generates a replacement for each linter",
@@ -212,8 +204,8 @@ func foo() {
212204
}`,
213205
expected: []issueWithReplacement{
214206
{
215-
"directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter1\" at testing.go:5:9",
216-
&result.Replacement{
207+
issue: "directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter1\" at testing.go:5:9",
208+
replacement: &result.Replacement{
217209
Inline: &result.InlineFix{
218210
StartCol: 17,
219211
Length: 8,
@@ -222,8 +214,8 @@ func foo() {
222214
},
223215
},
224216
{
225-
"directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter2\" at testing.go:5:9",
226-
&result.Replacement{
217+
issue: "directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter2\" at testing.go:5:9",
218+
replacement: &result.Replacement{
227219
Inline: &result.InlineFix{
228220
StartCol: 25,
229221
Length: 8,
@@ -232,8 +224,8 @@ func foo() {
232224
},
233225
},
234226
{
235-
"directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter3\" at testing.go:5:9",
236-
&result.Replacement{
227+
issue: "directive `//nolint:linter1,linter2,linter3` is unused for linter \"linter3\" at testing.go:5:9",
228+
replacement: &result.Replacement{
237229
Inline: &result.InlineFix{
238230
StartCol: 33,
239231
Length: 7,
@@ -254,8 +246,8 @@ func foo() {
254246
}`,
255247
expected: []issueWithReplacement{
256248
{
257-
"directive `//nolint:linter1, linter2` is unused for linter \"linter1\" at testing.go:5:10",
258-
&result.Replacement{
249+
issue: "directive `//nolint:linter1, linter2` is unused for linter \"linter1\" at testing.go:5:10",
250+
replacement: &result.Replacement{
259251
Inline: &result.InlineFix{
260252
StartCol: 18,
261253
Length: 8,
@@ -264,8 +256,8 @@ func foo() {
264256
},
265257
},
266258
{
267-
"directive `//nolint:linter1, linter2` is unused for linter \"linter2\" at testing.go:5:10",
268-
&result.Replacement{
259+
issue: "directive `//nolint:linter1, linter2` is unused for linter \"linter2\" at testing.go:5:10",
260+
replacement: &result.Replacement{
269261
Inline: &result.InlineFix{
270262
StartCol: 26,
271263
Length: 8,

0 commit comments

Comments
 (0)