diff --git a/.golangci.yml b/.golangci.yml index 8a00b01..4270301 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,52 +1,34 @@ version: "2" linters: enable: + - errcheck - errname - errorlint - exhaustive - - goprintffuncname + - gosec + - govet + - ineffassign - misspell - mnd - - tagliatelle + - modernize + - staticcheck + - tagalign - testpackage - thelper - tparallel - unconvert + - unused - wrapcheck - - wsl - disable: - - gochecknoglobals - settings: - gosec: - excludes: - - G204 - tagliatelle: - case: - rules: - json: snake - yaml: snake + - wsl_v5 exclusions: generated: lax presets: - - comments - common-false-positives - - legacy - - std-error-handling rules: - linters: - gosec path: _test\.go - paths: - - third_party$ - - builtin$ - - examples$ formatters: enable: - gofumpt - goimports - exclusions: - generated: lax - paths: - - third_party$ - - builtin$ - - examples$ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f063657..0151ad3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: end-of-file-fixer - id: check-merge-conflict - repo: https://github.com/golangci/golangci-lint - rev: v2.7.2 + rev: v2.10.1 hooks: - id: golangci-lint - repo: https://github.com/hadolint/hadolint diff --git a/alert_test.go b/alert_test.go index 220fda8..8494fa0 100644 --- a/alert_test.go +++ b/alert_test.go @@ -22,7 +22,6 @@ func TestAlertValidate(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -77,7 +76,6 @@ func TestAlertSend(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -123,7 +121,6 @@ func TestAlertBuildTemplate(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/config_test.go b/config_test.go index 0e72396..36baf26 100644 --- a/config_test.go +++ b/config_test.go @@ -24,7 +24,6 @@ func TestLoadConfig(t *testing.T) { {"./test/valid-config.hcl", nil, "Valid config file"}, } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -51,7 +50,7 @@ func TestDefaultConfig(t *testing.T) { m.Config{ CheckInterval: 1 * time.Second, DefaultAlertAfter: 2, - DefaultAlertEvery: Ptr(0), + DefaultAlertEvery: new(0), DefaultAlertDown: []string{"log_command"}, }, "override defaults", @@ -61,7 +60,7 @@ func TestDefaultConfig(t *testing.T) { m.Config{ CheckInterval: 30 * time.Second, DefaultAlertAfter: 1, - DefaultAlertEvery: Ptr(-1), + DefaultAlertEvery: new(-1), DefaultAlertDown: []string{}, }, "default defaults", @@ -69,7 +68,6 @@ func TestDefaultConfig(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/go.mod b/go.mod index 24acc49..2b5ca59 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.iamthefij.com/iamthefij/minitor-go/v2 -go 1.25.0 +go 1.26.0 require ( git.iamthefij.com/iamthefij/slog/v2 v2.0.1 diff --git a/main_test.go b/main_test.go index 2367548..632e7b5 100644 --- a/main_test.go +++ b/main_test.go @@ -6,10 +6,6 @@ import ( m "git.iamthefij.com/iamthefij/minitor-go/v2" ) -func Ptr[T any](v T) *T { - return &v -} - // TestCheckConfig tests the checkConfig function // It also tests results for potentially invalid configuration. For example, no alerts func TestCheckMonitors(t *testing.T) { @@ -91,7 +87,6 @@ func TestCheckMonitors(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -171,7 +166,6 @@ func TestFirstRunAlerts(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/monitor_test.go b/monitor_test.go index d0d880f..584e6b1 100644 --- a/monitor_test.go +++ b/monitor_test.go @@ -25,7 +25,6 @@ func TestMonitorValidate(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -103,7 +102,6 @@ func TestMonitorGetAlertNames(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -175,7 +173,6 @@ func TestMonitorFailureAlertAfter(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -204,15 +201,14 @@ func TestMonitorFailureAlertEvery(t *testing.T) { }{ {m.Monitor{ShellCommand: "false", AlertAfter: 1}, []bool{true}, "No AlertEvery set"}, // Defaults to true because AlertAfter and AlertEvery default to nil // Alert first time only, after 1 - {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(0)}, []bool{true, false, false}, "Alert first time only after 1"}, + {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(0)}, []bool{true, false, false}, "Alert first time only after 1"}, // Alert every time, after 1 - {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(1)}, []bool{true, true, true}, "Alert every time after 1"}, + {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(1)}, []bool{true, true, true}, "Alert every time after 1"}, // Alert every other time, after 1 - {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(2)}, []bool{true, false, true, false}, "Alert every other time after 1"}, + {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(2)}, []bool{true, false, true, false}, "Alert every other time after 1"}, } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -301,7 +297,6 @@ func TestMonitorCheck(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/util_test.go b/util_test.go index b4c1a22..568cf57 100644 --- a/util_test.go +++ b/util_test.go @@ -24,7 +24,6 @@ func TestUtilEqualSliceString(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("%v %v", c.a, c.b), func(t *testing.T) { t.Parallel()