diff --git a/.golangci.yml b/.golangci.yml index 9f2ada2..1aea9b0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,10 +2,10 @@ run: skip-dirs-use-default: true allow-parallel-runners: true modules-download-mode: readonly - tests: false output: - format: colored-line-number + formats: + - format: colored-line-number sort-results: true linters: @@ -23,7 +23,7 @@ linters: - dupl - errorlint - exhaustive - - exportloopref + - copyloopvar - funlen - gocognit - goconst @@ -32,7 +32,7 @@ linters: - godot - goimports - revive - - gomnd + - mnd - gosec - lll - makezero @@ -162,7 +162,7 @@ issues: - path: _test\.go linters: - dupl - - gomnd + - mnd - lll - bodyclose - errcheck diff --git a/core/logger/gin_test.go b/core/logger/gin_test.go index fb35633..ffc7350 100644 --- a/core/logger/gin_test.go +++ b/core/logger/gin_test.go @@ -2,7 +2,6 @@ package logger import ( "encoding/json" - "fmt" "net/http" "net/http/httptest" "testing" @@ -108,8 +107,8 @@ func TestSkippedPath(t *testing.T) { require.True(t, ok) for item, result := range items { - assert.Equal(t, result, matcher.match(item), fmt.Sprintf(`"%s" does not match "%s", internals: %#v`, - pattern, item, matcher)) + assert.Equal(t, result, matcher.match(item), `"%s" does not match "%s", internals: %#v`, + pattern, item, matcher) } } } diff --git a/core/util/testutil/buffer_logger.go b/core/util/testutil/buffer_logger.go index 4f9fcd6..0ea0ddf 100644 --- a/core/util/testutil/buffer_logger.go +++ b/core/util/testutil/buffer_logger.go @@ -37,7 +37,6 @@ type BufferedLogger interface { // // Some other code that works with logger. // fmt.Println(log.String()) type BufferLogger struct { - _ *zap.Logger logger.Default buf LockableBuffer } diff --git a/core/util/testutil/buffer_logger_test.go b/core/util/testutil/buffer_logger_test.go index 8eb5ac8..ff4920c 100644 --- a/core/util/testutil/buffer_logger_test.go +++ b/core/util/testutil/buffer_logger_test.go @@ -33,35 +33,35 @@ func (t *BufferLoggerTest) Test_Read() { data, err := io.ReadAll(t.logger) t.Require().NoError(err) - t.Assert().Contains(string(data), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(string(data), "\"message\":\"test\"") + t.Contains(string(data), "\"level_name\":\"DEBUG\"") + t.Contains(string(data), "\"message\":\"test\"") t.silentLogger.Debug("test") data, err = io.ReadAll(t.silentLogger) t.Require().NoError(err) - t.Assert().Contains(string(data), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(string(data), "\"message\":\"test\"") + t.Contains(string(data), "\"level_name\":\"DEBUG\"") + t.Contains(string(data), "\"message\":\"test\"") } func (t *BufferLoggerTest) Test_Bytes() { t.logger.Debug("test") - t.Assert().Contains(string(t.logger.Bytes()), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(string(t.logger.Bytes()), "\"message\":\"test\"") + t.Contains(string(t.logger.Bytes()), "\"level_name\":\"DEBUG\"") + t.Contains(string(t.logger.Bytes()), "\"message\":\"test\"") t.silentLogger.Debug("test") - t.Assert().Contains(string(t.silentLogger.Bytes()), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(string(t.silentLogger.Bytes()), "\"message\":\"test\"") + t.Contains(string(t.silentLogger.Bytes()), "\"level_name\":\"DEBUG\"") + t.Contains(string(t.silentLogger.Bytes()), "\"message\":\"test\"") } func (t *BufferLoggerTest) Test_String() { t.logger.Debug("test") - t.Assert().Contains(t.logger.String(), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(t.logger.String(), "\"message\":\"test\"") + t.Contains(t.logger.String(), "\"level_name\":\"DEBUG\"") + t.Contains(t.logger.String(), "\"message\":\"test\"") t.silentLogger.Debug("test") - t.Assert().Contains(t.silentLogger.String(), "\"level_name\":\"DEBUG\"") - t.Assert().Contains(t.silentLogger.String(), "\"message\":\"test\"") + t.Contains(t.silentLogger.String(), "\"level_name\":\"DEBUG\"") + t.Contains(t.silentLogger.String(), "\"message\":\"test\"") } func (t *BufferLoggerTest) TestRace() { diff --git a/core/validator_test.go b/core/validator_test.go index 4e23ccf..4683d44 100644 --- a/core/validator_test.go +++ b/core/validator_test.go @@ -41,7 +41,7 @@ func (s *ValidatorSuite) getError(err error) string { } func (s *ValidatorSuite) Test_ValidationInvalidType() { - s.Assert().IsType(&validator.InvalidValidationError{}, s.engine.Struct(nil)) + s.IsType(&validator.InvalidValidationError{}, s.engine.Struct(nil)) } func (s *ValidatorSuite) Test_ValidationFails() { @@ -62,7 +62,7 @@ func (s *ValidatorSuite) Test_ValidationFails() { err := s.engine.Struct(conn) s.Require().IsType(validator.ValidationErrors{}, err) - s.Assert().Equal( + s.Equal( "Key: 'Connection.URL' Error:Field validation for 'URL' failed on the 'validateCrmURL' tag", s.getError(err)) } @@ -80,7 +80,7 @@ func (s *ValidatorSuite) Test_ValidationSuccess() { crmDomains = append(crmDomains, "https://"+domain.Domain) } - s.Assert().True(len(crmDomains) > 4, "No box domains were tested, test is incomplete!") + s.Greater(len(crmDomains), 4, "No box domains were tested, test is incomplete!") for _, domain := range crmDomains { conn := models.Connection{ @@ -89,6 +89,6 @@ func (s *ValidatorSuite) Test_ValidationSuccess() { } err := s.engine.Struct(conn) - s.Assert().NoError(err, domain+": "+s.getError(err)) + s.NoError(err, domain+": "+s.getError(err)) } }