From fcb133d8cfe5831630496ec9ec939a15ccc36d24 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 23 Oct 2023 15:43:25 +0200 Subject: [PATCH] fix golangci critics --- .golangci.yml | 1 + internal_checks.go | 2 +- internal_negate_test.go | 4 ++-- readAndExecute_test.go | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 322c28f..af390b5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,6 +30,7 @@ linters: - forbidigo - ifshort - cyclop + - perfsprint - promlinter - varnamelen - nonamedreturns diff --git a/internal_checks.go b/internal_checks.go index ca3696c..68dabb2 100644 --- a/internal_checks.go +++ b/internal_checks.go @@ -7,7 +7,7 @@ import ( ) type InternalCheck interface { - Check(context.Context, *bytes.Buffer, []string) int + Check(ctx context.Context, output *bytes.Buffer, args []string) int } func execInternal(result *answer, cmd *command, received *receivedStruct) { diff --git a/internal_negate_test.go b/internal_negate_test.go index 1d579d4..daf9b77 100644 --- a/internal_negate_test.go +++ b/internal_negate_test.go @@ -12,8 +12,8 @@ func TestNegate(t *testing.T) { assert.Equal(t, Exec, cmd.ExecType, "exec type") assert.NotNil(t, cmd.Negate, "parsed negate") - assert.Equal(t, cmd.Negate.WarningStatus, "OK", "parsed negate") - assert.Equal(t, cmd.Negate.CriticalStatus, "UNKNOWN", "parsed negate") + assert.Equal(t, "OK", cmd.Negate.WarningStatus, "parsed negate") + assert.Equal(t, "UNKNOWN", cmd.Negate.CriticalStatus, "parsed negate") } func TestExecuteCommandWithNegateI(t *testing.T) { diff --git a/readAndExecute_test.go b/readAndExecute_test.go index 5bc69e2..61a7492 100644 --- a/readAndExecute_test.go +++ b/readAndExecute_test.go @@ -284,7 +284,7 @@ func BenchmarkParseCommandI(b *testing.B) { com := parseCommand(cmdLine, &config) assert.Equal(b, "/bin/test", com.Command, "command parsed") assert.Equalf(b, map[string]string{"VAR1": "test", "VAR2": "test"}, com.Env, "env parsed") - assert.Equal(b, 2, len(com.Args), "args parsed") + assert.Lenf(b, com.Args, 2, "args parsed") } func BenchmarkParseCommandII(b *testing.B) { @@ -297,5 +297,5 @@ func BenchmarkParseCommandII(b *testing.B) { com := parseCommand(cmdLine, &config) assert.Equal(b, "/bin/test", com.Command, "command parsed") assert.Equalf(b, map[string]string{"VAR1": "test", "VAR2": "test"}, com.Env, "env parsed") - assert.Equal(b, 13, len(com.Args), "args parsed") + assert.Lenf(b, com.Args, 13, "args parsed") }