Skip to content

Commit 03870e5

Browse files
authored
ci(lint): update and fix golangci-lint (#874)
1 parent 7eae8e8 commit 03870e5

File tree

6 files changed

+11
-32
lines changed

6 files changed

+11
-32
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
- name: golangci-lint
3232
uses: golangci/golangci-lint-action@v6
3333
with:
34-
version: v1.59
34+
version: v1.61

.golangci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
22
# Copyright (c) 2021 Marat Reymers
33

4-
## Golden config for golangci-lint v1.59.1
4+
## Golden config for golangci-lint v1.61.0
55
#
66
# This is the best config for golangci-lint based on my experience and opinion.
77
# It is very strict, but not extremely strict.
@@ -225,14 +225,13 @@ linters:
225225
- bidichk # checks for dangerous unicode character sequences
226226
- bodyclose # checks whether HTTP response body is closed successfully
227227
- canonicalheader # checks whether net/http.Header uses canonical header
228-
- copyloopvar # detects places where loop variables are copied
228+
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
229229
- cyclop # checks function and package cyclomatic complexity
230230
- dupl # tool for code clone detection
231231
- durationcheck # checks for two durations multiplied together
232232
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
233233
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
234234
- exhaustive # checks exhaustiveness of enum switch statements
235-
- exportloopref # checks for pointers to enclosing loop variables
236235
- fatcontext # detects nested contexts in loops
237236
- forbidigo # forbids identifiers
238237
- funlen # tool for detection of long functions
@@ -312,6 +311,7 @@ linters:
312311
#- err113 # [too strict] checks the errors handling expressions
313312
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/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
314313
#- execinquery # [deprecated] checks query string in Query function which reads your Go src files and warning it finds
314+
#- exportloopref # [not necessary from Go 1.22] checks for pointers to enclosing loop variables
315315
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
316316
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
317317
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed

notify_test.go

+3-17
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ func TestNew(t *testing.T) {
1313
t.Parallel()
1414

1515
n1 := New()
16-
if n1 == nil {
17-
t.Fatal("New() returned nil")
18-
}
16+
1917
if n1.Disabled {
2018
t.Fatal("New() returned disabled Notifier")
2119
}
@@ -56,9 +54,7 @@ func TestDefault(t *testing.T) {
5654
t.Parallel()
5755

5856
n := Default()
59-
if n == nil {
60-
t.Fatal("Default() returned nil")
61-
}
57+
6258
if n.Disabled {
6359
t.Fatal("Default() returned disabled Notifier")
6460
}
@@ -71,24 +67,14 @@ func TestDefault(t *testing.T) {
7167
func TestNewWithServices(t *testing.T) {
7268
t.Parallel()
7369

74-
n1 := NewWithServices()
75-
if n1 == nil {
76-
t.Fatal("NewWithServices() returned nil")
77-
}
78-
7970
n2 := NewWithServices(nil)
80-
if n2 == nil {
81-
t.Fatal("NewWithServices(nil) returned nil")
82-
}
71+
8372
if len(n2.notifiers) != 0 {
8473
t.Error("NewWithServices(nil) did not return empty Notifier")
8574
}
8675

8776
mailService := mail.New("", "")
8877
n3 := NewWithServices(mailService)
89-
if n3 == nil {
90-
t.Fatal("NewWithServices(mail.New()) returned nil")
91-
}
9278
if len(n3.notifiers) != 1 {
9379
t.Errorf("NewWithServices(mail.New()) was expected to have 1 notifier but had %d", len(n3.notifiers))
9480
} else {

send_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ func TestNotifySend(t *testing.T) {
1111
t.Parallel()
1212

1313
n := New()
14-
if n == nil {
15-
t.Fatal("New() returned nil")
16-
}
1714
if n.Disabled {
1815
t.Fatal("New() returned disabled Notifier")
1916
}

service/webpush/webpush_test.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ func Test_payloadFromContext(t *testing.T) {
615615
t.Parallel()
616616

617617
type args struct {
618-
ctx context.Context
619618
subject string
620619
message string
621620
data map[string]interface{}
@@ -629,7 +628,6 @@ func Test_payloadFromContext(t *testing.T) {
629628
{
630629
name: "Payload with only subject and message",
631630
args: args{
632-
ctx: context.Background(),
633631
subject: "test",
634632
message: "test",
635633
},
@@ -638,7 +636,6 @@ func Test_payloadFromContext(t *testing.T) {
638636
{
639637
name: "Payload with subject, message and data",
640638
args: args{
641-
ctx: context.Background(),
642639
subject: "test",
643640
message: "test",
644641
data: map[string]interface{}{
@@ -657,11 +654,13 @@ func Test_payloadFromContext(t *testing.T) {
657654
t.Run(tt.name, func(t *testing.T) {
658655
t.Parallel()
659656

657+
ctx := context.Background()
658+
660659
if tt.args.data != nil {
661-
tt.args.ctx = WithData(tt.args.ctx, tt.args.data)
660+
ctx = WithData(ctx, tt.args.data)
662661
}
663662

664-
got, err := payloadFromContext(tt.args.ctx, tt.args.subject, tt.args.message)
663+
got, err := payloadFromContext(ctx, tt.args.subject, tt.args.message)
665664
if (err != nil) != tt.wantErr {
666665
t.Errorf("payloadFromContext() error = %v, wantErr %v", err, tt.wantErr)
667666
return

use_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ func TestUseServices(t *testing.T) {
1010
t.Parallel()
1111

1212
n := New()
13-
if n == nil {
14-
t.Fatal("New() returned nil")
15-
}
1613
if len(n.notifiers) != 0 {
1714
t.Fatalf("Expected len(n.notifiers) == 0, got %d", len(n.notifiers))
1815
}

0 commit comments

Comments
 (0)