mirror of
https://github.com/nikoksr/notify.git
synced 2025-02-19 19:00:14 +02:00
ci(lint): update and fix golangci-lint (#874)
This commit is contained in:
parent
7eae8e81d9
commit
03870e5650
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -31,4 +31,4 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.59
|
||||
version: v1.61
|
||||
|
@ -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.
|
||||
@ -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
|
||||
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
@ -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")
|
||||
}
|
||||
@ -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 {
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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{}
|
||||
@ -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",
|
||||
},
|
||||
@ -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{}{
|
||||
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user