Skip to content

Commit

Permalink
fix var-shadows-builtin lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturRibeiro-CX committed Feb 25, 2025
1 parent d0bfc17 commit 0954762
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CxPolicy[result] {
}
}

check_array_size(array) {
is_array(array)
count(array) == 0
check_array_size(array_obj) {
is_array(array_obj)
count(array_obj) == 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ hasPodDisruptionBudget(statefulset) = result {
result := containsLabel(pdb, statefulset.spec.selector.matchLabels)
} else = false

containsLabel(array, label) {
array.spec.selector.matchLabels[_] == label[_]
containsLabel(array_obj, label_value) {
array_obj.spec.selector.matchLabels[_] == label_value[_]
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ CxPolicy[result] {
}
}

array_contains(array, string) {
array[_] == string
array_contains(array_obj, string) {
array_obj[_] == string
}
20 changes: 10 additions & 10 deletions assets/queries/openAPI/2.0/unknown_property/query.rego
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ CxPolicy[result] {
[path, value] := walk(doc)

objectValues := {"array": array_objects, "simple": simple_objects, "map": map_objects}
objValues := objectValues[objType][object]
objValues := objectValues[objType][obj]

index := {"array": 1, "simple": 1, "map": 2}
path[count(path) - index[objType]] == object
path[count(path) - index[objType]] == obj

objType == "array"
is_array(value)
Expand All @@ -42,8 +42,8 @@ CxPolicy[result] {
"documentId": doc.id,
"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), field]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, object]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, object]),
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, obj]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, obj]),
}
}

Expand All @@ -54,10 +54,10 @@ CxPolicy[result] {
[path, value] := walk(doc)

objectValues := {"array": array_objects, "simple": simple_objects, "map": map_objects}
objValues := objectValues[objType][object]
objValues := objectValues[objType][obj]

index := {"array": 1, "simple": 1, "map": 2}
path[count(path) - index[objType]] == object
path[count(path) - index[objType]] == obj

any([objType == "simple", objType == "map"])
value[field]
Expand All @@ -67,8 +67,8 @@ CxPolicy[result] {
"documentId": doc.id,
"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), field]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, object]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, object]),
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, obj]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, obj]),
}
}

Expand All @@ -94,8 +94,8 @@ known_swagger_object_field(field) {
field == swagger[_]
}

known_field(object, value) {
object[_] == value
known_field(obj, value) {
obj[_] == value
}

parameters_properties := {
Expand Down
20 changes: 10 additions & 10 deletions assets/queries/openAPI/3.0/unknown_property/query.rego
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ CxPolicy[result] {
[path, value] := walk(doc)

objectValues := {"array": array_objects, "simple": simple_objects, "map": map_objects}
objValues := objectValues[objType][object]
objValues := objectValues[objType][obj]

index := {"array": 1, "simple": 1, "map": 2}
path[count(path) - index[objType]] == object
path[count(path) - index[objType]] == obj

objType == "array"
is_array(value)
Expand All @@ -42,8 +42,8 @@ CxPolicy[result] {
"documentId": doc.id,
"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), field]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, object]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, object]),
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, obj]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, obj]),
}
}

Expand All @@ -54,10 +54,10 @@ CxPolicy[result] {
[path, value] := walk(doc)

objectValues := {"array": array_objects, "simple": simple_objects, "map": map_objects}
objValues := objectValues[objType][object]
objValues := objectValues[objType][obj]

index := {"array": 1, "simple": 1, "map": 2}
path[count(path) - index[objType]] == object
path[count(path) - index[objType]] == obj

any([objType == "simple", objType == "map"])
value[field]
Expand All @@ -67,8 +67,8 @@ CxPolicy[result] {
"documentId": doc.id,
"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), field]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, object]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, object]),
"keyExpectedValue": sprintf("The field '%s' is known in the %s object", [field, obj]),
"keyActualValue": sprintf("The field '%s' is unknown in the %s object", [field, obj]),
}
}

Expand Down Expand Up @@ -107,8 +107,8 @@ known_openapi_object_field(field) {
field == openapi[_]
}

known_field(object, value) {
object[_] == value
known_field(obj, value) {
obj[_] == value
}

flow := {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ CxPolicy[result] {
}
}

inArray(array, elem) {
startswith(array[_], elem)
inArray(array_obj, elem) {
startswith(array_obj[_], elem)
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ CxPolicy[result] {
}
}

drop(array, elem) {
upper(array[_]) == elem[_]
drop(array_obj, elem) {
upper(array_obj[_]) == elem[_]
}

0 comments on commit 0954762

Please sign in to comment.