@@ -89,7 +89,7 @@ func testCompareValues(t *testing.T, cmp comparator, name string, tests []compar
89
89
}
90
90
91
91
func TestCompareByLine (t * testing.T ) {
92
- testCompareValues (t , & byLine {} , "Compare By Line" , []compareTestCase {
92
+ testCompareValues (t , byLine () , "Compare By Line" , []compareTestCase {
93
93
{issues [0 ], issues [1 ], less }, // 10 vs 11
94
94
{issues [0 ], issues [0 ], equal }, // 10 vs 10
95
95
{issues [3 ], issues [3 ], equal }, // 10 vs 10
@@ -105,7 +105,7 @@ func TestCompareByLine(t *testing.T) {
105
105
}
106
106
107
107
func TestCompareByFileName (t * testing.T ) { //nolint:dupl
108
- testCompareValues (t , & byFileName {} , "Compare By File Name" , []compareTestCase {
108
+ testCompareValues (t , byFileName () , "Compare By File Name" , []compareTestCase {
109
109
{issues [0 ], issues [1 ], greater }, // file_windows.go vs file_linux.go
110
110
{issues [1 ], issues [2 ], greater }, // file_linux.go vs file_darwin.go
111
111
{issues [2 ], issues [3 ], equal }, // file_darwin.go vs file_darwin.go
@@ -120,7 +120,7 @@ func TestCompareByFileName(t *testing.T) { //nolint:dupl
120
120
}
121
121
122
122
func TestCompareByColumn (t * testing.T ) { //nolint:dupl
123
- testCompareValues (t , & byColumn {} , "Compare By Column" , []compareTestCase {
123
+ testCompareValues (t , byColumn () , "Compare By Column" , []compareTestCase {
124
124
{issues [0 ], issues [1 ], greater }, // 80 vs 70
125
125
{issues [1 ], issues [2 ], none }, // 70 vs zero value
126
126
{issues [3 ], issues [3 ], equal }, // 60 vs 60
@@ -135,7 +135,7 @@ func TestCompareByColumn(t *testing.T) { //nolint:dupl
135
135
}
136
136
137
137
func TestCompareByLinter (t * testing.T ) { //nolint:dupl
138
- testCompareValues (t , & byLinter {} , "Compare By Linter" , []compareTestCase {
138
+ testCompareValues (t , byLinter () , "Compare By Linter" , []compareTestCase {
139
139
{issues [0 ], issues [1 ], greater }, // b vs a
140
140
{issues [1 ], issues [2 ], less }, // a vs c
141
141
{issues [2 ], issues [3 ], equal }, // c vs c
@@ -150,7 +150,7 @@ func TestCompareByLinter(t *testing.T) { //nolint:dupl
150
150
}
151
151
152
152
func TestCompareBySeverity (t * testing.T ) {
153
- testCompareValues (t , & bySeverity {} , "Compare By Severity" , []compareTestCase {
153
+ testCompareValues (t , bySeverity () , "Compare By Severity" , []compareTestCase {
154
154
{issues [0 ], issues [1 ], greater }, // medium vs low
155
155
{issues [1 ], issues [2 ], less }, // low vs high
156
156
{issues [2 ], issues [3 ], equal }, // high vs high
@@ -167,11 +167,7 @@ func TestCompareBySeverity(t *testing.T) {
167
167
}
168
168
169
169
func TestCompareNested (t * testing.T ) {
170
- var cmp = & byFileName {
171
- next : & byLine {
172
- next : & byColumn {},
173
- },
174
- }
170
+ cmp := byFileName ().AddNext (byLine ().AddNext (byColumn ()))
175
171
176
172
testCompareValues (t , cmp , "Nested Comparing" , []compareTestCase {
177
173
{issues [1 ], issues [0 ], less }, // file_linux.go vs file_windows.go
@@ -188,7 +184,7 @@ func TestCompareNested(t *testing.T) {
188
184
}
189
185
190
186
func TestNumericCompare (t * testing.T ) {
191
- var tests = []struct {
187
+ tests : = []struct {
192
188
a , b int
193
189
expected compareResult
194
190
}{
@@ -214,23 +210,23 @@ func TestNumericCompare(t *testing.T) {
214
210
}
215
211
216
212
func TestNoSorting (t * testing.T ) {
217
- var tests = make ([]result.Issue , len (issues ))
213
+ tests : = make ([]result.Issue , len (issues ))
218
214
copy (tests , issues )
219
215
220
- var sr = NewSortResults (& config.Config {})
216
+ sr : = NewSortResults (& config.Config {})
221
217
222
218
results , err := sr .Process (tests )
223
219
require .NoError (t , err )
224
220
assert .Equal (t , tests , results )
225
221
}
226
222
227
223
func TestSorting (t * testing.T ) {
228
- var tests = make ([]result.Issue , len (issues ))
224
+ tests : = make ([]result.Issue , len (issues ))
229
225
copy (tests , issues )
230
226
231
- var cfg = config.Config {}
227
+ cfg : = config.Config {}
232
228
cfg .Output .SortResults = true
233
- var sr = NewSortResults (& cfg )
229
+ sr : = NewSortResults (& cfg )
234
230
235
231
results , err := sr .Process (tests )
236
232
require .NoError (t , err )
@@ -245,22 +241,22 @@ func Test_mergeComparators(t *testing.T) {
245
241
}{
246
242
{
247
243
desc : "one" ,
248
- cmps : []comparator {& byLinter {} },
244
+ cmps : []comparator {byLinter () },
249
245
expected : "byLinter" ,
250
246
},
251
247
{
252
248
desc : "two" ,
253
- cmps : []comparator {& byLinter {}, & byFileName {} },
249
+ cmps : []comparator {byLinter (), byFileName () },
254
250
expected : "byLinter > byFileName" ,
255
251
},
256
252
{
257
253
desc : "all" ,
258
- cmps : []comparator {& bySeverity {}, & byLinter {}, & byFileName {}, & byLine {}, & byColumn {} },
254
+ cmps : []comparator {bySeverity (), byLinter (), byFileName (), byLine (), byColumn () },
259
255
expected : "bySeverity > byLinter > byFileName > byLine > byColumn" ,
260
256
},
261
257
{
262
258
desc : "all reverse" ,
263
- cmps : []comparator {& byColumn {}, & byLine {}, & byFileName {}, & byLinter {}, & bySeverity {} },
259
+ cmps : []comparator {byColumn (), byLine (), byFileName (), byLinter (), bySeverity () },
264
260
expected : "byColumn > byLine > byFileName > byLinter > bySeverity" ,
265
261
},
266
262
}
0 commit comments