kyaml: fix scopelint issues

This commit is contained in:
Igor Zibarev
2019-11-12 23:42:02 +03:00
parent 912a9c3baa
commit 301e529a4a
3 changed files with 5 additions and 5 deletions

View File

@@ -286,7 +286,7 @@ func (f FieldMatcher) Filter(rn *RNode) (*RNode, error) {
return nil, err
}
for i := 0; i < len(rn.Content()); IncrementFieldIndex(&i) {
for i := 0; i < len(rn.Content()); i = IncrementFieldIndex(i) {
isMatchingField := rn.Content()[i].Value == f.Name
if isMatchingField {
requireMatchFieldValue := f.Value != nil
@@ -592,6 +592,6 @@ func SplitIndexNameValue(p string) (string, string, error) {
// IncrementFieldIndex increments i to point to the next field name element in
// a slice of Contents.
func IncrementFieldIndex(i *int) {
*i = *i + 2
func IncrementFieldIndex(i int) int {
return i + 2
}

View File

@@ -419,7 +419,7 @@ func (rn *RNode) Field(field string) *MapNode {
if rn.YNode().Kind != yaml.MappingNode {
return nil
}
for i := 0; i < len(rn.Content()); IncrementFieldIndex(&i) {
for i := 0; i < len(rn.Content()); i = IncrementFieldIndex(i) {
isMatchingField := rn.Content()[i].Value == field
if isMatchingField {
return &MapNode{Key: NewRNode(rn.Content()[i]), Value: NewRNode(rn.Content()[i+1])}