Skip to content

Commit 9c6ece2

Browse files
committed
style(golangci-lint): add new linters
1 parent 98c0280 commit 9c6ece2

8 files changed

+39
-25
lines changed

.golangci.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ linters:
148148
- err113 # Golang linter to check the errors handling expressions
149149
- gocritic # Provides many diagnostics that check for bugs, performance and style issues.
150150
- exhaustive # Check exhaustiveness of enum switch statements
151-
- exportloopref # checks for pointers to enclosing loop variables -- VERY IMPORTANT TO USE
152151
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
153152
- forcetypeassert # finds forced type assertions
154153
- importas # Enforces consistent import aliases
@@ -178,6 +177,21 @@ linters:
178177
- reassign # Checks that package variables are not reassigne
179178
- musttag # linter that enforces field tags in (un)marshaled structslinter that enforces field tags in (un)marshaled structs
180179
- dupword # checks for duplicate words in the source code comments.
180+
- testableexamples # checks if examples are testable (have an expected output)
181+
- fatcontext # Detects potential fat contexts in loops or function literals.
182+
- copyloopvar # Detects places where loop variables are copied.
183+
- intrange # Detect loops that could use the Go 1.22 integer range feature.
184+
- perfsprint # Detects performance issues with fmt.Sprintf.
185+
- inamedparam # Detects interfaces with unnamed method parameters.
186+
- gochecksumtype # Detects the use of checksum types in Go code.
187+
- mirror # Use right mirror functions for string/[]byte performance bust.
188+
- tagalign # Align and sort tags for Go struct.
189+
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
190+
- nilnesserr # Detects nil errors in Go code.
191+
- usetesting # Detects when some calls can be replaced by methods from the testing package.
192+
- recvcheck # Golang linter checks for receiver type consistency.
193+
- iface # Detects the incorrect use of interfaces.
194+
181195
issues:
182196
exclude-use-default: false
183197
include:

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
repos:
22
- repo: https://github.com/commitizen-tools/commitizen
3-
rev: v2.42.1
3+
rev: v4.1.0
44
hooks:
55
- id: commitizen
66
- repo: https://github.com/golangci/golangci-lint
7-
rev: v1.52.0
7+
rev: v1.63.3
88
hooks:
99
- id: golangci-lint
1010
name: golangci-lint

blocking_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func TestBlocking(t *testing.T) {
155155
queueElems := blockingQueue.Clear()
156156

157157
if !reflect.DeepEqual(elems, queueElems) {
158-
t.Fatalf("expected elems to be %v, got %v", elems, queueElems)
158+
t.Fatalf("expected elements to be %v, got %v", elems, queueElems)
159159
}
160160
})
161161

@@ -167,7 +167,7 @@ func TestBlocking(t *testing.T) {
167167
queueElems := blockingQueue.Clear()
168168

169169
if len(queueElems) != 0 {
170-
t.Fatalf("expected elems to be empty, got %v", queueElems)
170+
t.Fatalf("expected elements to be empty, got %v", queueElems)
171171
}
172172
})
173173
})
@@ -220,7 +220,7 @@ func TestBlocking(t *testing.T) {
220220
}
221221

222222
if !reflect.DeepEqual(elems, iterElems) {
223-
t.Fatalf("expected elems to be %v, got %v", elems, iterElems)
223+
t.Fatalf("expected elements to be %v, got %v", elems, iterElems)
224224
}
225225
})
226226

circular_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestCircular(t *testing.T) {
134134
expectedElems := []int{1, 2}
135135

136136
if !reflect.DeepEqual(expectedElems, queueElems) {
137-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
137+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
138138
}
139139
})
140140

@@ -170,7 +170,7 @@ func TestCircular(t *testing.T) {
170170
expectedElems := []int{5, 6, 3, 4}
171171

172172
if !reflect.DeepEqual(expectedElems, queueElems) {
173-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
173+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
174174
}
175175
})
176176
})
@@ -232,7 +232,7 @@ func TestCircular(t *testing.T) {
232232
expectedElems := []int{2, 3, 4}
233233

234234
if !reflect.DeepEqual(expectedElems, queueElems) {
235-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
235+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
236236
}
237237
})
238238

@@ -265,7 +265,7 @@ func TestCircular(t *testing.T) {
265265
expectedElems := []int{1, 2, 3, 4}
266266

267267
if !reflect.DeepEqual(expectedElems, queueElems) {
268-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
268+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
269269
}
270270
})
271271

@@ -287,7 +287,7 @@ func TestCircular(t *testing.T) {
287287
}
288288

289289
if !reflect.DeepEqual(elems, iterElems) {
290-
t.Fatalf("expected elems to be %v, got %v", elems, iterElems)
290+
t.Fatalf("expected elements to be %v, got %v", elems, iterElems)
291291
}
292292
})
293293
}

linked_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func TestLinked(t *testing.T) {
111111
expectedElems := []int{1, 2}
112112

113113
if !reflect.DeepEqual(expectedElems, queueElems) {
114-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
114+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
115115
}
116116
})
117117
})
@@ -173,7 +173,7 @@ func TestLinked(t *testing.T) {
173173
expectedElems := []int{2, 3, 4}
174174

175175
if !reflect.DeepEqual(expectedElems, queueElems) {
176-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
176+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
177177
}
178178
})
179179

@@ -206,7 +206,7 @@ func TestLinked(t *testing.T) {
206206
expectedElems := []int{1, 2, 3, 4}
207207

208208
if !reflect.DeepEqual(expectedElems, queueElems) {
209-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
209+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
210210
}
211211
})
212212

@@ -228,7 +228,7 @@ func TestLinked(t *testing.T) {
228228
}
229229

230230
if !reflect.DeepEqual(elems, iterElems) {
231-
t.Fatalf("expected elems to be %v, got %v", elems, iterElems)
231+
t.Fatalf("expected elements to be %v, got %v", elems, iterElems)
232232
}
233233
})
234234
}

options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type options struct {
66

77
// An Option configures a Queue using the functional options paradigm.
88
type Option interface {
9-
apply(*options)
9+
apply(o *options)
1010
}
1111

1212
type capacityOption int

priority_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ func TestPriority(t *testing.T) {
4141
size := priorityQueue.Size()
4242

4343
if priorityQueue.Size() != 2 {
44-
t.Fatalf("expected size to be 2, got %d with elems: %v", size, priorityQueue.Clear())
44+
t.Fatalf("expected size to be 2, got %d with elements: %v", size, priorityQueue.Clear())
4545
}
4646

4747
elems = priorityQueue.Clear()
4848
expectedElems := []int{1, 2}
4949

5050
if !reflect.DeepEqual([]int{1, 2}, elems) {
51-
t.Fatalf("expected elems to be %v, got %v", expectedElems, elems)
51+
t.Fatalf("expected elements to be %v, got %v", expectedElems, elems)
5252
}
5353
})
5454

@@ -76,7 +76,7 @@ func TestPriority(t *testing.T) {
7676
expectedElems := []int{1, 2, 4, 5}
7777

7878
if !reflect.DeepEqual(expectedElems, queueElems) {
79-
t.Fatalf("expected elems to be %v, got %v", expectedElems, queueElems)
79+
t.Fatalf("expected elements to be %v, got %v", expectedElems, queueElems)
8080
}
8181

8282
newElems := make([]int, 10)
@@ -91,7 +91,7 @@ func TestPriority(t *testing.T) {
9191

9292
queueElems = priorityQueue.Clear()
9393
if !reflect.DeepEqual(newElems, queueElems) {
94-
t.Fatalf("expected elems to be %v, got %v", newElems, queueElems)
94+
t.Fatalf("expected elements to be %v, got %v", newElems, queueElems)
9595
}
9696
})
9797

@@ -161,7 +161,7 @@ func TestPriority(t *testing.T) {
161161
queueElems := priorityQueue.Clear()
162162

163163
if !reflect.DeepEqual(elems, queueElems) {
164-
t.Fatalf("expected elems to be %v, got %v", elems, queueElems)
164+
t.Fatalf("expected elements to be %v, got %v", elems, queueElems)
165165
}
166166
})
167167

@@ -173,7 +173,7 @@ func TestPriority(t *testing.T) {
173173
queueElems := priorityQueue.Clear()
174174

175175
if len(queueElems) != 0 {
176-
t.Fatalf("expected elems to be empty, got %v", queueElems)
176+
t.Fatalf("expected elements to be empty, got %v", queueElems)
177177
}
178178
})
179179
})
@@ -226,7 +226,7 @@ func TestPriority(t *testing.T) {
226226
}
227227

228228
if !reflect.DeepEqual(elems, iterElems) {
229-
t.Fatalf("expected elems to be %v, got %v", elems, iterElems)
229+
t.Fatalf("expected elements to be %v, got %v", elems, iterElems)
230230
}
231231
})
232232

queue_interface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ type Queue[T comparable] interface {
1313
Get() (T, error)
1414

1515
// Offer inserts the element to the tail of the queue.
16-
Offer(T) error
16+
Offer(elem T) error
1717

1818
// Reset sets the queue to its initial state.
1919
Reset()
2020

2121
// Contains returns true if the queue contains the element.
22-
Contains(T) bool
22+
Contains(elem T) bool
2323

2424
// Peek retrieves but does not remove the head of the queue.
2525
Peek() (T, error)

0 commit comments

Comments
 (0)