mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
kyaml: fix scopelint issues
This commit is contained in:
@@ -31,7 +31,7 @@ linters:
|
|||||||
# - lll
|
# - lll
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
# - scopelint
|
- scopelint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
- structcheck
|
||||||
# - stylecheck
|
# - stylecheck
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ func (f FieldMatcher) Filter(rn *RNode) (*RNode, error) {
|
|||||||
return nil, err
|
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
|
isMatchingField := rn.Content()[i].Value == f.Name
|
||||||
if isMatchingField {
|
if isMatchingField {
|
||||||
requireMatchFieldValue := f.Value != nil
|
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
|
// IncrementFieldIndex increments i to point to the next field name element in
|
||||||
// a slice of Contents.
|
// a slice of Contents.
|
||||||
func IncrementFieldIndex(i *int) {
|
func IncrementFieldIndex(i int) int {
|
||||||
*i = *i + 2
|
return i + 2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ func (rn *RNode) Field(field string) *MapNode {
|
|||||||
if rn.YNode().Kind != yaml.MappingNode {
|
if rn.YNode().Kind != yaml.MappingNode {
|
||||||
return nil
|
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
|
isMatchingField := rn.Content()[i].Value == field
|
||||||
if isMatchingField {
|
if isMatchingField {
|
||||||
return &MapNode{Key: NewRNode(rn.Content()[i]), Value: NewRNode(rn.Content()[i+1])}
|
return &MapNode{Key: NewRNode(rn.Content()[i]), Value: NewRNode(rn.Content()[i+1])}
|
||||||
|
|||||||
Reference in New Issue
Block a user