From 29caefd7e3fc70d8f6188987e515cc8a298cc4dd Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Mon, 4 Mar 2024 08:33:05 +0100 Subject: [PATCH] chore(lint): relinted Signed-off-by: Frederic BIDON --- analyzer_test.go | 4 ++-- flatten_test.go | 6 +++--- internal/debug/debug.go | 4 ++-- mixin.go | 14 +++++++------- schema.go | 4 ++-- schema_test.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/analyzer_test.go b/analyzer_test.go index e03283c..57331f5 100644 --- a/analyzer_test.go +++ b/analyzer_test.go @@ -456,7 +456,7 @@ func TestAnalyzer_ParamsAsMapWithCallback(t *testing.T) { require.True(t, ok) pi.Parameters = pi.PathItemProps.Get.OperationProps.Parameters - s.paramsAsMap(pi.Parameters, m, func(param spec.Parameter, err error) bool { + s.paramsAsMap(pi.Parameters, m, func(_ spec.Parameter, err error) bool { e = append(e, err.Error()) return false // Bail @@ -493,7 +493,7 @@ func TestAnalyzer_ParamsAsMapPanic(t *testing.T) { "fixture-342-3.yaml", } { fixture := toPin - t.Run(fmt.Sprintf("panic_%s", fixture), func(t *testing.T) { + t.Run("panic_"+fixture, func(t *testing.T) { t.Parallel() s := prepareTestParamsInvalid(t, fixture) diff --git a/flatten_test.go b/flatten_test.go index 738c2d5..e6fd2e3 100644 --- a/flatten_test.go +++ b/flatten_test.go @@ -753,7 +753,7 @@ func TestFlatten_OAIGen(t *testing.T) { filepath.Join("fixtures", "oaigen", "test3-bis-swagger.yaml"), filepath.Join("fixtures", "oaigen", "test3-ter-swagger.yaml"), } { - t.Run(fmt.Sprintf("flatten_oiagen_1260_%s", fixture), func(t *testing.T) { + t.Run("flatten_oiagen_1260_"+fixture, func(t *testing.T) { t.Parallel() bp := filepath.Join("fixtures", "oaigen", "test3-swagger.yaml") @@ -1045,7 +1045,7 @@ func TestFlatten_Issue_1602_All(t *testing.T) { filepath.Join("fixtures", "bugs", "1602", "fixture-1602-6.yaml"), } { fixture := toPin - t.Run(fmt.Sprintf("issue_1602_all_%s", fixture), func(t *testing.T) { + t.Run("issue_1602_all_"+fixture, func(t *testing.T) { t.Parallel() sp := antest.LoadOrFail(t, fixture) @@ -1235,7 +1235,7 @@ func TestFlatten_RemoteAbsolute(t *testing.T) { filepath.Join("fixtures", "bugs", "remote-absolute", "swagger-with-remote-only-ref.json"), } { fixture := toPin - t.Run(fmt.Sprintf("remote_absolute_%s", fixture), func(t *testing.T) { + t.Run("remote_absolute_"+fixture, func(t *testing.T) { t.Parallel() an := testFlattenWithDefaults(t, fixture) diff --git a/internal/debug/debug.go b/internal/debug/debug.go index ec0fec0..39f55a9 100644 --- a/internal/debug/debug.go +++ b/internal/debug/debug.go @@ -29,7 +29,7 @@ var ( // GetLogger provides a prefix debug logger func GetLogger(prefix string, debug bool) func(string, ...interface{}) { if debug { - logger := log.New(output, fmt.Sprintf("%s:", prefix), log.LstdFlags) + logger := log.New(output, prefix+":", log.LstdFlags) return func(msg string, args ...interface{}) { _, file1, pos1, _ := runtime.Caller(1) @@ -37,5 +37,5 @@ func GetLogger(prefix string, debug bool) func(string, ...interface{}) { } } - return func(msg string, args ...interface{}) {} + return func(_ string, _ ...interface{}) {} } diff --git a/mixin.go b/mixin.go index 57cb7a9..7785a29 100644 --- a/mixin.go +++ b/mixin.go @@ -53,7 +53,7 @@ import ( // collisions. func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string { skipped := make([]string, 0, len(mixins)) - opIds := getOpIds(primary) + opIDs := getOpIDs(primary) initPrimary(primary) for i, m := range mixins { @@ -74,7 +74,7 @@ func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string { skipped = append(skipped, mergeDefinitions(primary, m)...) // merging paths requires a map of operationIDs to work with - skipped = append(skipped, mergePaths(primary, m, opIds, i)...) + skipped = append(skipped, mergePaths(primary, m, opIDs, i)...) skipped = append(skipped, mergeParameters(primary, m)...) @@ -84,9 +84,9 @@ func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string { return skipped } -// getOpIds extracts all the paths..operationIds from the given +// getOpIDs extracts all the paths..operationIds from the given // spec and returns them as the keys in a map with 'true' values. -func getOpIds(s *spec.Swagger) map[string]bool { +func getOpIDs(s *spec.Swagger) map[string]bool { rv := make(map[string]bool) if s.Paths == nil { return rv @@ -179,7 +179,7 @@ func mergeDefinitions(primary *spec.Swagger, m *spec.Swagger) (skipped []string) return } -func mergePaths(primary *spec.Swagger, m *spec.Swagger, opIds map[string]bool, mixIndex int) (skipped []string) { +func mergePaths(primary *spec.Swagger, m *spec.Swagger, opIDs map[string]bool, mixIndex int) (skipped []string) { if m.Paths != nil { for k, v := range m.Paths.Paths { if _, exists := primary.Paths.Paths[k]; exists { @@ -198,10 +198,10 @@ func mergePaths(primary *spec.Swagger, m *spec.Swagger, opIds map[string]bool, m // all the proivded specs are already unique. piops := pathItemOps(v) for _, piop := range piops { - if opIds[piop.ID] { + if opIDs[piop.ID] { piop.ID = fmt.Sprintf("%v%v%v", piop.ID, "Mixin", mixIndex) } - opIds[piop.ID] = true + opIDs[piop.ID] = true } primary.Paths.Paths[k] = v } diff --git a/schema.go b/schema.go index 95f35dc..ab190db 100644 --- a/schema.go +++ b/schema.go @@ -1,7 +1,7 @@ package analysis import ( - "fmt" + "errors" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" @@ -19,7 +19,7 @@ type SchemaOpts struct { // patterns. func Schema(opts SchemaOpts) (*AnalyzedSchema, error) { if opts.Schema == nil { - return nil, fmt.Errorf("no schema to analyze") + return nil, errors.New("no schema to analyze") } a := &AnalyzedSchema{ diff --git a/schema_test.go b/schema_test.go index cf5fb0b..02e321e 100644 --- a/schema_test.go +++ b/schema_test.go @@ -310,7 +310,7 @@ func refSchema(ref spec.Ref) *spec.Schema { } func schemaHandler(schema *spec.Schema) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { writeJSON(w, schema) }) }