Skip to content

Commit

Permalink
Update No Ref Siblings to Use Rolodex
Browse files Browse the repository at this point in the history
Remove extra spacing between lines

Add whitespace to match original file
  • Loading branch information
califlower committed Sep 6, 2024
1 parent b4e7718 commit 7bc6a72
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions functions/openapi/no_ref_siblings.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,23 @@ func (nrs NoRefSiblings) RunRule(nodes []*yaml.Node, context model.RuleFunctionC
}

var results []model.RuleFunctionResult
siblings := context.Index.GetReferencesWithSiblings()
for _, ref := range siblings {

key, val := utils.FindKeyNode("$ref", ref.Node.Content)
results = append(results, model.RuleFunctionResult{
Message: "a `$ref` cannot be placed next to any other properties",
StartNode: key,
EndNode: vacuumUtils.BuildEndNode(val),
Path: ref.Path,
Rule: context.Rule,
})

for _, idx := range context.Index.GetRolodex().GetIndexes() {

siblings := idx.GetReferencesWithSiblings()
for _, ref := range siblings {

key, val := utils.FindKeyNode("$ref", ref.Node.Content)
results = append(results, model.RuleFunctionResult{
Message: "a `$ref` cannot be placed next to any other properties",
StartNode: key,
Origin: idx.FindNodeOrigin(val),
EndNode: vacuumUtils.BuildEndNode(val),
Path: ref.Path,
Rule: context.Rule,
})
}
}

return results
}

0 comments on commit 7bc6a72

Please sign in to comment.