Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(lint): update and fix golangci-lint #874

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
6 changes: 3 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021 Marat Reymers

## Golden config for golangci-lint v1.59.1
## Golden config for golangci-lint v1.61.0
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
Expand Down Expand Up @@ -225,14 +225,13 @@ linters:
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- canonicalheader # checks whether net/http.Header uses canonical header
- copyloopvar # detects places where loop variables are copied
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
- cyclop # checks function and package cyclomatic complexity
- dupl # tool for code clone detection
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- fatcontext # detects nested contexts in loops
- forbidigo # forbids identifiers
- funlen # tool for detection of long functions
Expand Down Expand Up @@ -312,6 +311,7 @@ linters:
#- err113 # [too strict] checks the errors handling expressions
#- 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
#- execinquery # [deprecated] checks query string in Query function which reads your Go src files and warning it finds
#- exportloopref # [not necessary from Go 1.22] checks for pointers to enclosing loop variables
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
Expand Down
20 changes: 3 additions & 17 deletions notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ func TestNew(t *testing.T) {
t.Parallel()

n1 := New()
if n1 == nil {
t.Fatal("New() returned nil")
}

if n1.Disabled {
t.Fatal("New() returned disabled Notifier")
}
Expand Down Expand Up @@ -56,9 +54,7 @@ func TestDefault(t *testing.T) {
t.Parallel()

n := Default()
if n == nil {
t.Fatal("Default() returned nil")
}

if n.Disabled {
t.Fatal("Default() returned disabled Notifier")
}
Expand All @@ -71,24 +67,14 @@ func TestDefault(t *testing.T) {
func TestNewWithServices(t *testing.T) {
t.Parallel()

n1 := NewWithServices()
if n1 == nil {
t.Fatal("NewWithServices() returned nil")
}

n2 := NewWithServices(nil)
if n2 == nil {
t.Fatal("NewWithServices(nil) returned nil")
}

if len(n2.notifiers) != 0 {
t.Error("NewWithServices(nil) did not return empty Notifier")
}

mailService := mail.New("", "")
n3 := NewWithServices(mailService)
if n3 == nil {
t.Fatal("NewWithServices(mail.New()) returned nil")
}
if len(n3.notifiers) != 1 {
t.Errorf("NewWithServices(mail.New()) was expected to have 1 notifier but had %d", len(n3.notifiers))
} else {
Expand Down
3 changes: 0 additions & 3 deletions send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ func TestNotifySend(t *testing.T) {
t.Parallel()

n := New()
if n == nil {
t.Fatal("New() returned nil")
}
if n.Disabled {
t.Fatal("New() returned disabled Notifier")
}
Expand Down
9 changes: 4 additions & 5 deletions service/webpush/webpush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ func Test_payloadFromContext(t *testing.T) {
t.Parallel()

type args struct {
ctx context.Context
subject string
message string
data map[string]interface{}
Expand All @@ -629,7 +628,6 @@ func Test_payloadFromContext(t *testing.T) {
{
name: "Payload with only subject and message",
args: args{
ctx: context.Background(),
subject: "test",
message: "test",
},
Expand All @@ -638,7 +636,6 @@ func Test_payloadFromContext(t *testing.T) {
{
name: "Payload with subject, message and data",
args: args{
ctx: context.Background(),
subject: "test",
message: "test",
data: map[string]interface{}{
Expand All @@ -657,11 +654,13 @@ func Test_payloadFromContext(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

ctx := context.Background()

if tt.args.data != nil {
tt.args.ctx = WithData(tt.args.ctx, tt.args.data)
ctx = WithData(ctx, tt.args.data)
}

got, err := payloadFromContext(tt.args.ctx, tt.args.subject, tt.args.message)
got, err := payloadFromContext(ctx, tt.args.subject, tt.args.message)
if (err != nil) != tt.wantErr {
t.Errorf("payloadFromContext() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down
3 changes: 0 additions & 3 deletions use_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ func TestUseServices(t *testing.T) {
t.Parallel()

n := New()
if n == nil {
t.Fatal("New() returned nil")
}
if len(n.notifiers) != 0 {
t.Fatalf("Expected len(n.notifiers) == 0, got %d", len(n.notifiers))
}
Expand Down
Loading