Skip to content

Commit

Permalink
Small bugfixes in exit code and unused_components (#102)
Browse files Browse the repository at this point in the history
* Fixed bug with return code after running SOAR pipeline

The wrong error code was being returned, so now it’s not!

Signed-off-by: Dave Shanley <dshanley@splunk.com>

* unused_component rule upgraded

Now searches through polymorphic references, this was caught
after running the SOAR pipeline.

Signed-off-by: Dave Shanley <dshanley@splunk.com>
  • Loading branch information
daveshanley authored Jul 26, 2022
1 parent 6194828 commit 64bb59d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/shared_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ func CheckFailureSeverity(failSeverityFlag string, errors int, warnings int, inf
if failSeverityFlag != "error" {
switch failSeverityFlag {
case "warn":
if errors > 0 && warnings > 0 {
if warnings > 0 {
return fmt.Errorf("failed linting, with %d errors and %d warnings", errors, warnings)
}
return nil
case "info":
if errors > 0 && warnings > 0 && informs > 0 {
if informs > 0 {
return fmt.Errorf("failed linting, with %d errors, %d warnings and %d informs",
errors, warnings, informs)
}
Expand Down
4 changes: 4 additions & 0 deletions functions/openapi/unused_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (uc UnusedComponent) RunRule(nodes []*yaml.Node, context model.RuleFunction
links := context.Index.GetAllLinks()
callbacks := context.Index.GetAllCallbacks()

for _, ref := range context.Index.GetPolyAllOfReferences() {
allRefs[ref.Definition] = ref
}

// if a component does not exist in allRefs, it was not referenced anywhere.
notUsed := make(map[string]*index.Reference)

Expand Down

0 comments on commit 64bb59d

Please sign in to comment.