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

Update No Ref Siblings to Use Rolodex #543

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
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
}
Loading