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
|
||||
- misspell
|
||||
- nakedret
|
||||
# - scopelint
|
||||
- scopelint
|
||||
- staticcheck
|
||||
- structcheck
|
||||
# - stylecheck
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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])}
|
||||
|
||||
Reference in New Issue
Block a user