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
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v6
|
||||||
with:
|
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
|
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
|
||||||
# Copyright (c) 2021 Marat Reymers
|
# 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.
|
# This is the best config for golangci-lint based on my experience and opinion.
|
||||||
# It is very strict, but not extremely strict.
|
# It is very strict, but not extremely strict.
|
||||||
@ -225,14 +225,13 @@ linters:
|
|||||||
- bidichk # checks for dangerous unicode character sequences
|
- bidichk # checks for dangerous unicode character sequences
|
||||||
- bodyclose # checks whether HTTP response body is closed successfully
|
- bodyclose # checks whether HTTP response body is closed successfully
|
||||||
- canonicalheader # checks whether net/http.Header uses canonical header
|
- 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
|
- cyclop # checks function and package cyclomatic complexity
|
||||||
- dupl # tool for code clone detection
|
- dupl # tool for code clone detection
|
||||||
- durationcheck # checks for two durations multiplied together
|
- 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
|
- 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
|
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
|
||||||
- exhaustive # checks exhaustiveness of enum switch statements
|
- exhaustive # checks exhaustiveness of enum switch statements
|
||||||
- exportloopref # checks for pointers to enclosing loop variables
|
|
||||||
- fatcontext # detects nested contexts in loops
|
- fatcontext # detects nested contexts in loops
|
||||||
- forbidigo # forbids identifiers
|
- forbidigo # forbids identifiers
|
||||||
- funlen # tool for detection of long functions
|
- funlen # tool for detection of long functions
|
||||||
@ -312,6 +311,7 @@ linters:
|
|||||||
#- err113 # [too strict] checks the errors handling expressions
|
#- 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
|
#- 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
|
#- 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
|
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
|
||||||
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
|
#- 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
|
#- 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()
|
t.Parallel()
|
||||||
|
|
||||||
n1 := New()
|
n1 := New()
|
||||||
if n1 == nil {
|
|
||||||
t.Fatal("New() returned nil")
|
|
||||||
}
|
|
||||||
if n1.Disabled {
|
if n1.Disabled {
|
||||||
t.Fatal("New() returned disabled Notifier")
|
t.Fatal("New() returned disabled Notifier")
|
||||||
}
|
}
|
||||||
@ -56,9 +54,7 @@ func TestDefault(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
n := Default()
|
n := Default()
|
||||||
if n == nil {
|
|
||||||
t.Fatal("Default() returned nil")
|
|
||||||
}
|
|
||||||
if n.Disabled {
|
if n.Disabled {
|
||||||
t.Fatal("Default() returned disabled Notifier")
|
t.Fatal("Default() returned disabled Notifier")
|
||||||
}
|
}
|
||||||
@ -71,24 +67,14 @@ func TestDefault(t *testing.T) {
|
|||||||
func TestNewWithServices(t *testing.T) {
|
func TestNewWithServices(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
n1 := NewWithServices()
|
|
||||||
if n1 == nil {
|
|
||||||
t.Fatal("NewWithServices() returned nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
n2 := NewWithServices(nil)
|
n2 := NewWithServices(nil)
|
||||||
if n2 == nil {
|
|
||||||
t.Fatal("NewWithServices(nil) returned nil")
|
|
||||||
}
|
|
||||||
if len(n2.notifiers) != 0 {
|
if len(n2.notifiers) != 0 {
|
||||||
t.Error("NewWithServices(nil) did not return empty Notifier")
|
t.Error("NewWithServices(nil) did not return empty Notifier")
|
||||||
}
|
}
|
||||||
|
|
||||||
mailService := mail.New("", "")
|
mailService := mail.New("", "")
|
||||||
n3 := NewWithServices(mailService)
|
n3 := NewWithServices(mailService)
|
||||||
if n3 == nil {
|
|
||||||
t.Fatal("NewWithServices(mail.New()) returned nil")
|
|
||||||
}
|
|
||||||
if len(n3.notifiers) != 1 {
|
if len(n3.notifiers) != 1 {
|
||||||
t.Errorf("NewWithServices(mail.New()) was expected to have 1 notifier but had %d", len(n3.notifiers))
|
t.Errorf("NewWithServices(mail.New()) was expected to have 1 notifier but had %d", len(n3.notifiers))
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,9 +11,6 @@ func TestNotifySend(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
n := New()
|
n := New()
|
||||||
if n == nil {
|
|
||||||
t.Fatal("New() returned nil")
|
|
||||||
}
|
|
||||||
if n.Disabled {
|
if n.Disabled {
|
||||||
t.Fatal("New() returned disabled Notifier")
|
t.Fatal("New() returned disabled Notifier")
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,6 @@ func Test_payloadFromContext(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
|
||||||
subject string
|
subject string
|
||||||
message string
|
message string
|
||||||
data map[string]interface{}
|
data map[string]interface{}
|
||||||
@ -629,7 +628,6 @@ func Test_payloadFromContext(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Payload with only subject and message",
|
name: "Payload with only subject and message",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.Background(),
|
|
||||||
subject: "test",
|
subject: "test",
|
||||||
message: "test",
|
message: "test",
|
||||||
},
|
},
|
||||||
@ -638,7 +636,6 @@ func Test_payloadFromContext(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Payload with subject, message and data",
|
name: "Payload with subject, message and data",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.Background(),
|
|
||||||
subject: "test",
|
subject: "test",
|
||||||
message: "test",
|
message: "test",
|
||||||
data: map[string]interface{}{
|
data: map[string]interface{}{
|
||||||
@ -657,11 +654,13 @@ func Test_payloadFromContext(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
if tt.args.data != nil {
|
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 {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("payloadFromContext() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("payloadFromContext() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
|
@ -10,9 +10,6 @@ func TestUseServices(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
n := New()
|
n := New()
|
||||||
if n == nil {
|
|
||||||
t.Fatal("New() returned nil")
|
|
||||||
}
|
|
||||||
if len(n.notifiers) != 0 {
|
if len(n.notifiers) != 0 {
|
||||||
t.Fatalf("Expected len(n.notifiers) == 0, got %d", len(n.notifiers))
|
t.Fatalf("Expected len(n.notifiers) == 0, got %d", len(n.notifiers))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user