Skip to content

Commit

Permalink
remove unused params (Tufin#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenharrison authored Oct 15, 2024
1 parent 2987584 commit aa40875
Show file tree
Hide file tree
Showing 39 changed files with 146 additions and 148 deletions.
6 changes: 2 additions & 4 deletions checker/check_api_security_updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
APIGlobalSecurityScopeRemovedId = "api-global-security-scope-removed"
)

func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config *Config) Changes {
func checkGlobalSecurity(diffReport *diff.Diff) Changes {
result := make(Changes, 0)
if diffReport.SecurityDiff == nil {
return result
Expand Down Expand Up @@ -57,13 +57,12 @@ func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.Operatio
}

return result

}

func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config *Config) Changes {
result := make(Changes, 0)

result = append(result, checkGlobalSecurity(diffReport, operationsSources, config)...)
result = append(result, checkGlobalSecurity(diffReport)...)

if diffReport.PathsDiff == nil || diffReport.PathsDiff.Modified == nil {
return result
Expand Down Expand Up @@ -144,7 +143,6 @@ func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Oper
}
}
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions checker/check_components_security_updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (

const ComponentSecuritySchemes = "securitySchemes"

func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config *Config, updatedSecurityName string) Changes {
func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, updatedSecurityName string) Changes {
result := make(Changes, 0)

if updatedSecurity.OAuthFlowsDiff == nil {
Expand Down Expand Up @@ -104,7 +104,7 @@ func APIComponentsSecurityUpdatedCheck(diffReport *diff.Diff, operationsSources
}

for updatedSecurityName, updatedSecurity := range diffReport.ComponentsDiff.SecuritySchemesDiff.Modified {
result = append(result, checkOAuthUpdates(updatedSecurity, config, updatedSecurityName)...)
result = append(result, checkOAuthUpdates(updatedSecurity, updatedSecurityName)...)

if updatedSecurity.TypeDiff != nil {
result = append(result, ComponentChange{
Expand Down
28 changes: 14 additions & 14 deletions checker/checks-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ func CheckAddedPropertiesDiff(schemaDiff *diff.SchemaDiff, processor func(proper
if schemaDiff == nil {
return
}
processAddedPropertiesDiff("", "", schemaDiff, nil, processor)
processAddedPropertiesDiff("", "", schemaDiff, processor)
}

func processAddedPropertiesDiff(propertyPath string, propertyName string, schemaDiff *diff.SchemaDiff, parentDiff *diff.SchemaDiff, processor func(propertyPath string, propertyName string, propertyItem *openapi3.Schema, propertyParentDiff *diff.SchemaDiff)) {
func processAddedPropertiesDiff(propertyPath string, propertyName string, schemaDiff *diff.SchemaDiff, processor func(propertyPath string, propertyName string, propertyItem *openapi3.Schema, propertyParentDiff *diff.SchemaDiff)) {
if propertyName != "" {
if propertyPath == "" {
propertyPath = propertyName
Expand All @@ -129,32 +129,32 @@ func processAddedPropertiesDiff(propertyPath string, propertyName string, schema

if schemaDiff.AllOfDiff != nil {
for _, v := range schemaDiff.AllOfDiff.Modified {
processAddedPropertiesDiff(fmt.Sprintf("%s/allOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processAddedPropertiesDiff(fmt.Sprintf("%s/allOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}

if schemaDiff.AnyOfDiff != nil {
for _, v := range schemaDiff.AnyOfDiff.Modified {
processAddedPropertiesDiff(fmt.Sprintf("%s/anyOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processAddedPropertiesDiff(fmt.Sprintf("%s/anyOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}

if schemaDiff.OneOfDiff != nil {
for _, v := range schemaDiff.OneOfDiff.Modified {
processAddedPropertiesDiff(fmt.Sprintf("%s/oneOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processAddedPropertiesDiff(fmt.Sprintf("%s/oneOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}

if schemaDiff.ItemsDiff != nil {
processAddedPropertiesDiff(fmt.Sprintf("%s/items", propertyPath), "", schemaDiff.ItemsDiff, schemaDiff, processor)
processAddedPropertiesDiff(fmt.Sprintf("%s/items", propertyPath), "", schemaDiff.ItemsDiff, processor)
}

if schemaDiff.PropertiesDiff != nil {
for _, v := range schemaDiff.PropertiesDiff.Added {
processor(propertyPath, v, schemaDiff.Revision.Properties[v].Value, schemaDiff)
}
for i, v := range schemaDiff.PropertiesDiff.Modified {
processAddedPropertiesDiff(propertyPath, i, v, schemaDiff, processor)
processAddedPropertiesDiff(propertyPath, i, v, processor)
}
}
}
Expand All @@ -164,10 +164,10 @@ func CheckDeletedPropertiesDiff(schemaDiff *diff.SchemaDiff, processor func(prop
return
}

processDeletedPropertiesDiff("", "", schemaDiff, nil, processor)
processDeletedPropertiesDiff("", "", schemaDiff, processor)
}

func processDeletedPropertiesDiff(propertyPath string, propertyName string, schemaDiff *diff.SchemaDiff, parentDiff *diff.SchemaDiff, processor func(propertyPath string, propertyName string, propertyItem *openapi3.Schema, propertyParentDiff *diff.SchemaDiff)) {
func processDeletedPropertiesDiff(propertyPath string, propertyName string, schemaDiff *diff.SchemaDiff, processor func(propertyPath string, propertyName string, propertyItem *openapi3.Schema, propertyParentDiff *diff.SchemaDiff)) {
if propertyName != "" {
if propertyPath == "" {
propertyPath = propertyName
Expand All @@ -178,31 +178,31 @@ func processDeletedPropertiesDiff(propertyPath string, propertyName string, sche

if schemaDiff.AllOfDiff != nil {
for _, v := range schemaDiff.AllOfDiff.Modified {
processDeletedPropertiesDiff(fmt.Sprintf("%s/allOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processDeletedPropertiesDiff(fmt.Sprintf("%s/allOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}
if schemaDiff.AnyOfDiff != nil {
for _, v := range schemaDiff.AnyOfDiff.Modified {
processDeletedPropertiesDiff(fmt.Sprintf("%s/anyOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processDeletedPropertiesDiff(fmt.Sprintf("%s/anyOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}

if schemaDiff.OneOfDiff != nil {
for _, v := range schemaDiff.OneOfDiff.Modified {
processDeletedPropertiesDiff(fmt.Sprintf("%s/oneOf[%s]", propertyPath, v), "", v.Diff, schemaDiff, processor)
processDeletedPropertiesDiff(fmt.Sprintf("%s/oneOf[%s]", propertyPath, v), "", v.Diff, processor)
}
}

if schemaDiff.ItemsDiff != nil {
processDeletedPropertiesDiff(fmt.Sprintf("%s/items", propertyPath), "", schemaDiff.ItemsDiff, schemaDiff, processor)
processDeletedPropertiesDiff(fmt.Sprintf("%s/items", propertyPath), "", schemaDiff.ItemsDiff, processor)
}

if schemaDiff.PropertiesDiff != nil {
for _, v := range schemaDiff.PropertiesDiff.Deleted {
processor(propertyPath, v, schemaDiff.Base.Properties[v].Value, schemaDiff)
}
for i, v := range schemaDiff.PropertiesDiff.Modified {
processDeletedPropertiesDiff(propertyPath, i, v, schemaDiff, processor)
processDeletedPropertiesDiff(propertyPath, i, v, processor)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions diff/components_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getComponentsDiffInternal(config *Config, state *state, s1, s2 openapi3.Com
return result, err
}

result.ParametersDiff, err = getParametersDiff(config, state, s1.Parameters, s2.Parameters, PathParamsMap{})
result.ParametersDiff, err = getParametersDiff(config, state, s1.Parameters, s2.Parameters)
if err != nil {
return result, err
}
Expand All @@ -56,17 +56,17 @@ func getComponentsDiffInternal(config *Config, state *state, s1, s2 openapi3.Com
return result, err
}

result.SecuritySchemesDiff, err = getSecuritySchemesDiff(config, state, s1.SecuritySchemes, s2.SecuritySchemes)
result.SecuritySchemesDiff, err = getSecuritySchemesDiff(config, s1.SecuritySchemes, s2.SecuritySchemes)
if err != nil {
return result, err
}

result.ExamplesDiff, err = getExamplesDiff(config, state, s1.Examples, s2.Examples)
result.ExamplesDiff, err = getExamplesDiff(config, s1.Examples, s2.Examples)
if err != nil {
return result, err
}

result.LinksDiff, err = getLinksDiff(config, state, s1.Links, s2.Links)
result.LinksDiff, err = getLinksDiff(config, s1.Links, s2.Links)
if err != nil {
return result, err
}
Expand Down
8 changes: 4 additions & 4 deletions diff/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func (diff *ContactDiff) Empty() bool {
return diff == nil || *diff == ContactDiff{}
}

func getContactDiff(config *Config, state *state, contact1, contact2 *openapi3.Contact) (*ContactDiff, error) {
diff, err := getContactDiffInternal(config, state, contact1, contact2)
func getContactDiff(config *Config, contact1, contact2 *openapi3.Contact) (*ContactDiff, error) {
diff, err := getContactDiffInternal(config, contact1, contact2)
if err != nil {
return nil, err
}
Expand All @@ -32,7 +32,7 @@ func getContactDiff(config *Config, state *state, contact1, contact2 *openapi3.C
return diff, nil
}

func getContactDiffInternal(config *Config, state *state, contact1, contact2 *openapi3.Contact) (*ContactDiff, error) {
func getContactDiffInternal(config *Config, contact1, contact2 *openapi3.Contact) (*ContactDiff, error) {

result := ContactDiff{}
var err error
Expand All @@ -51,7 +51,7 @@ func getContactDiffInternal(config *Config, state *state, contact1, contact2 *op
return &result, nil
}

result.ExtensionsDiff, err = getExtensionsDiff(config, state, contact1.Extensions, contact2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, contact1.Extensions, contact2.Extensions)
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ func getDiffInternal(config *Config, state *state, s1, s2 *openapi3.T) (*Diff, e
result := newDiff()
var err error

result.ExtensionsDiff, err = getExtensionsDiff(config, state, s1.Extensions, s2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, s1.Extensions, s2.Extensions)
if err != nil {
return nil, err
}
result.OpenAPIDiff = getValueDiff(s1.OpenAPI, s2.OpenAPI)
result.InfoDiff, err = getInfoDiff(config, state, s1.Info, s2.Info)
result.InfoDiff, err = getInfoDiff(config, s1.Info, s2.Info)
if err != nil {
return nil, err
}
Expand All @@ -283,10 +283,10 @@ func getDiffInternal(config *Config, state *state, s1, s2 *openapi3.T) (*Diff, e
return nil, err
}

result.SecurityDiff = getSecurityRequirementsDiff(config, state, &s1.Security, &s2.Security)
result.ServersDiff = getServersDiff(config, state, &s1.Servers, &s2.Servers)
result.TagsDiff = getTagsDiff(config, state, s1.Tags, s2.Tags)
result.ExternalDocsDiff, err = getExternalDocsDiff(config, state, s1.ExternalDocs, s2.ExternalDocs)
result.SecurityDiff = getSecurityRequirementsDiff(&s1.Security, &s2.Security)
result.ServersDiff = getServersDiff(config, &s1.Servers, &s2.Servers)
result.TagsDiff = getTagsDiff(config, s1.Tags, s2.Tags)
result.ExternalDocsDiff, err = getExternalDocsDiff(config, s1.ExternalDocs, s2.ExternalDocs)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions diff/discriminator_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func newDiscriminatorDiff() *DiscriminatorDiff {

}

func getDiscriminatorDiff(config *Config, state *state, discriminator1, discriminator2 *openapi3.Discriminator) (*DiscriminatorDiff, error) {
diff, err := getDiscriminatorDiffInternal(config, state, discriminator1, discriminator2)
func getDiscriminatorDiff(config *Config, discriminator1, discriminator2 *openapi3.Discriminator) (*DiscriminatorDiff, error) {
diff, err := getDiscriminatorDiffInternal(config, discriminator1, discriminator2)
if err != nil {
return nil, err
}
Expand All @@ -36,7 +36,7 @@ func getDiscriminatorDiff(config *Config, state *state, discriminator1, discrimi
return diff, nil
}

func getDiscriminatorDiffInternal(config *Config, state *state, discriminator1, discriminator2 *openapi3.Discriminator) (*DiscriminatorDiff, error) {
func getDiscriminatorDiffInternal(config *Config, discriminator1, discriminator2 *openapi3.Discriminator) (*DiscriminatorDiff, error) {

result := newDiscriminatorDiff()
var err error
Expand All @@ -55,7 +55,7 @@ func getDiscriminatorDiffInternal(config *Config, state *state, discriminator1,
return result, nil
}

result.ExtensionsDiff, err = getExtensionsDiff(config, state, discriminator1.Extensions, discriminator2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, discriminator1.Extensions, discriminator2.Extensions)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion diff/encoding_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getEncodingDiffInternal(config *Config, state *state, value1, value2 *opena
return nil, fmt.Errorf("encoding is nil")
}

result.ExtensionsDiff, err = getExtensionsDiff(config, state, value1.Extensions, value2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, value1.Extensions, value2.Extensions)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion diff/enum_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (enumDiff *EnumDiff) Empty() bool {
len(enumDiff.Deleted) == 0
}

func getEnumDiff(config *Config, state *state, enum1, enum2 EnumValues) *EnumDiff {
func getEnumDiff(enum1, enum2 EnumValues) *EnumDiff {

diff := getEnumDiffInternal(enum1, enum2)

Expand Down
8 changes: 4 additions & 4 deletions diff/example_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func (diff *ExampleDiff) Empty() bool {
return diff == nil || *diff == ExampleDiff{}
}

func getExampleDiff(config *Config, state *state, value1, value2 *openapi3.Example) (*ExampleDiff, error) {
diff, err := getExampleDiffInternal(config, state, value1, value2)
func getExampleDiff(config *Config, value1, value2 *openapi3.Example) (*ExampleDiff, error) {
diff, err := getExampleDiffInternal(config, value1, value2)
if err != nil {
return nil, err
}
Expand All @@ -31,11 +31,11 @@ func getExampleDiff(config *Config, state *state, value1, value2 *openapi3.Examp
return diff, nil
}

func getExampleDiffInternal(config *Config, state *state, value1, value2 *openapi3.Example) (*ExampleDiff, error) {
func getExampleDiffInternal(config *Config, value1, value2 *openapi3.Example) (*ExampleDiff, error) {
result := ExampleDiff{}
var err error

result.ExtensionsDiff, err = getExtensionsDiff(config, state, value1.Extensions, value2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, value1.Extensions, value2.Extensions)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions diff/examples_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func newExamplessDiff() *ExamplesDiff {
}
}

func getExamplesDiff(config *Config, state *state, examples1, examples2 openapi3.Examples) (*ExamplesDiff, error) {
func getExamplesDiff(config *Config, examples1, examples2 openapi3.Examples) (*ExamplesDiff, error) {

diff, err := getExamplesDiffInternal(config, state, examples1, examples2)
diff, err := getExamplesDiffInternal(config, examples1, examples2)
if err != nil {
return nil, err
}
Expand All @@ -50,7 +50,7 @@ func getExamplesDiff(config *Config, state *state, examples1, examples2 openapi3
return diff, nil
}

func getExamplesDiffInternal(config *Config, state *state, examples1, examples2 openapi3.Examples) (*ExamplesDiff, error) {
func getExamplesDiffInternal(config *Config, examples1, examples2 openapi3.Examples) (*ExamplesDiff, error) {

if config.IsExcludeExamples() {
return nil, nil
Expand All @@ -71,7 +71,7 @@ func getExamplesDiffInternal(config *Config, state *state, examples1, examples2
return nil, err
}

diff, err := getExampleDiff(config, state, value1, value2)
diff, err := getExampleDiff(config, value1, value2)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions diff/extensions_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ func (diff *ExtensionsDiff) Empty() bool {
return (*InterfaceMapDiff)(diff).Empty()
}

func getExtensionsDiff(config *Config, state *state, extensions1, extensions2 map[string]interface{}) (*ExtensionsDiff, error) {
func getExtensionsDiff(config *Config, extensions1, extensions2 map[string]interface{}) (*ExtensionsDiff, error) {
if config.IsExcludeExtensions() {
return nil, nil
}

diff, err := getExtensionsDiffInternal(state, extensions1, extensions2)
diff, err := getExtensionsDiffInternal(extensions1, extensions2)
if err != nil {
return nil, err
}
Expand All @@ -25,6 +25,6 @@ func getExtensionsDiff(config *Config, state *state, extensions1, extensions2 ma
return (*ExtensionsDiff)(diff), nil
}

func getExtensionsDiffInternal(state *state, extensions1, extensions2 map[string]interface{}) (*InterfaceMapDiff, error) {
func getExtensionsDiffInternal(extensions1, extensions2 map[string]interface{}) (*InterfaceMapDiff, error) {
return getInterfaceMapDiff(extensions1, extensions2)
}
8 changes: 4 additions & 4 deletions diff/external_docs_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func (diff *ExternalDocsDiff) Empty() bool {
return diff == nil || *diff == ExternalDocsDiff{}
}

func getExternalDocsDiff(config *Config, state *state, docs1, docs2 *openapi3.ExternalDocs) (*ExternalDocsDiff, error) {
diff, err := getExternalDocsDiffInternal(config, state, docs1, docs2)
func getExternalDocsDiff(config *Config, docs1, docs2 *openapi3.ExternalDocs) (*ExternalDocsDiff, error) {
diff, err := getExternalDocsDiffInternal(config, docs1, docs2)
if err != nil {
return nil, err
}
Expand All @@ -35,7 +35,7 @@ func getExternalDocsDiff(config *Config, state *state, docs1, docs2 *openapi3.Ex
return diff, nil
}

func getExternalDocsDiffInternal(config *Config, state *state, docs1, docs2 *openapi3.ExternalDocs) (*ExternalDocsDiff, error) {
func getExternalDocsDiffInternal(config *Config, docs1, docs2 *openapi3.ExternalDocs) (*ExternalDocsDiff, error) {
result := newExternalDocsDiff()
var err error

Expand All @@ -53,7 +53,7 @@ func getExternalDocsDiffInternal(config *Config, state *state, docs1, docs2 *ope
return result, nil
}

result.ExtensionsDiff, err = getExtensionsDiff(config, state, docs1.Extensions, docs2.Extensions)
result.ExtensionsDiff, err = getExtensionsDiff(config, docs1.Extensions, docs2.Extensions)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit aa40875

Please sign in to comment.