From 54f3f808233fe0e807e39fa0c1c3bb035b0a43c2 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Mon, 4 Mar 2024 10:38:25 +0100 Subject: [PATCH] chore(lint): relinted Signed-off-by: Frederic BIDON --- convert_test.go | 4 ++-- initialism_index.go | 2 +- loading_test.go | 10 +++++----- yaml.go | 3 ++- yaml_test.go | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/convert_test.go b/convert_test.go index fd531e1..dc5c09b 100644 --- a/convert_test.go +++ b/convert_test.go @@ -54,7 +54,7 @@ func TestConvertFloat32(t *testing.T) { for _, f := range validFloats { c, err := ConvertFloat32(FormatFloat32(f)) require.NoError(t, err) - assert.EqualValues(t, f, c) + assert.InDelta(t, f, c, 1e-6) } for _, f := range invalidFloats { _, err := ConvertFloat32(f) @@ -69,7 +69,7 @@ func TestConvertFloat64(t *testing.T) { for _, f := range validFloats { c, err := ConvertFloat64(FormatFloat64(f)) require.NoError(t, err) - assert.EqualValues(t, f, c) + assert.InDelta(t, f, c, 1e-6) } for _, f := range invalidFloats { _, err := ConvertFloat64(f) diff --git a/initialism_index.go b/initialism_index.go index 2b2e463..20a359b 100644 --- a/initialism_index.go +++ b/initialism_index.go @@ -176,7 +176,7 @@ func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { func (m *indexOfInitialisms) sorted() (result []string) { m.sortMutex.Lock() defer m.sortMutex.Unlock() - m.index.Range(func(key, value interface{}) bool { + m.index.Range(func(key, _ interface{}) bool { k := key.(string) result = append(result, k) return true diff --git a/loading_test.go b/loading_test.go index fad3e77..9f68c07 100644 --- a/loading_test.go +++ b/loading_test.go @@ -36,7 +36,7 @@ func TestLoadFromHTTP(t *testing.T) { _, err := LoadFromFileOrHTTP("httx://12394:abd") require.Error(t, err) - serv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + serv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { rw.WriteHeader(http.StatusNotFound) })) defer serv.Close() @@ -44,7 +44,7 @@ func TestLoadFromHTTP(t *testing.T) { _, err = LoadFromFileOrHTTP(serv.URL) require.Error(t, err) - ts2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + ts2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { rw.WriteHeader(http.StatusOK) _, _ = rw.Write([]byte("the content")) })) @@ -137,10 +137,10 @@ func TestLoadHTTPBytes(t *testing.T) { } func TestLoadStrategy(t *testing.T) { - loader := func(p string) ([]byte, error) { + loader := func(_ string) ([]byte, error) { return []byte(yamlPetStore), nil } - remLoader := func(p string) ([]byte, error) { + remLoader := func(_ string) ([]byte, error) { return []byte("not it"), nil } @@ -187,7 +187,7 @@ func TestLoadStrategyFile(t *testing.T) { } } - remLoader := func(p string) ([]byte, error) { + remLoader := func(_ string) ([]byte, error) { return []byte(thisIsNotIt), nil } diff --git a/yaml.go b/yaml.go index a8c4e35..f59e025 100644 --- a/yaml.go +++ b/yaml.go @@ -16,6 +16,7 @@ package swag import ( "encoding/json" + "errors" "fmt" "path/filepath" "reflect" @@ -50,7 +51,7 @@ func BytesToYAMLDoc(data []byte) (interface{}, error) { return nil, err } if document.Kind != yaml.DocumentNode || len(document.Content) != 1 || document.Content[0].Kind != yaml.MappingNode { - return nil, fmt.Errorf("only YAML documents that are objects are supported") + return nil, errors.New("only YAML documents that are objects are supported") } return &document, nil } diff --git a/yaml_test.go b/yaml_test.go index 3dd0065..5299a96 100644 --- a/yaml_test.go +++ b/yaml_test.go @@ -201,7 +201,7 @@ name: a string value assert.Equal(t, json.RawMessage(`{"description":"object created"}`), d) } -var yamlPestoreServer = func(rw http.ResponseWriter, r *http.Request) { +var yamlPestoreServer = func(rw http.ResponseWriter, _ *http.Request) { rw.WriteHeader(http.StatusOK) _, _ = rw.Write([]byte(yamlPetStore)) }