Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lint): relinted #105

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions flatten_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ 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)
logger.Printf("%s:%d: %s", filepath.Base(file1), pos1, fmt.Sprintf(msg, args...))
}
}

return func(msg string, args ...interface{}) {}
return func(_ string, _ ...interface{}) {}
}
14 changes: 7 additions & 7 deletions mixin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)...)

Expand All @@ -84,9 +84,9 @@ func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string {
return skipped
}

// getOpIds extracts all the paths.<path>.operationIds from the given
// getOpIDs extracts all the paths.<path>.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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions schema.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package analysis

import (
"fmt"
"errors"

"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
Loading