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

prefer-some-in-iteration no longer reporting violation as expected #901

Closed
anderseknert opened this issue Jul 7, 2024 · 0 comments · Fixed by #902
Closed

prefer-some-in-iteration no longer reporting violation as expected #901

anderseknert opened this issue Jul 7, 2024 · 0 comments · Fixed by #902
Labels
bug Something isn't working rule

Comments

@anderseknert
Copy link
Member

Taking the example from the prefer-some-in-iteration rule doesn't seem to report the violation:

package policy

import rego.v1

engineering_roles := {"engineer", "dba", "developer"}

engineers contains employee if {
    employee := data.employees[_]
    employee.role in engineering_roles
}
❯ regal lint p.rego
1 file linted. No violations found.
@anderseknert anderseknert added bug Something isn't working rule labels Jul 7, 2024
anderseknert added a commit that referenced this issue Jul 7, 2024
This was due to an unfortunate combination of trying to be lenient
about `coll[_]` used in the position of a function arg (as that's not
*directly* replaceable by `some .. in` **but** not excluding operators
like `:=` from functions (where it _should_ be replaced by `some .. in`)
**and** many tests for this rule missing to provide the built-in functions
as a mocked dependency.

Will need to think some about how to best avoid this to happen again.

Fixes #901

Signed-off-by: Anders Eknert <[email protected]>
anderseknert added a commit that referenced this issue Jul 7, 2024
This was due to an unfortunate combination of trying to be lenient
about `coll[_]` used in the position of a function arg (as that's not
*directly* replaceable by `some .. in` **but** not excluding operators
like `:=` from functions (where it _should_ be replaced by `some .. in`)
**and** many tests for this rule missing to provide the built-in functions
as a mocked dependency.

Will need to think some about how to best avoid this to happen again.

Also:
- Replace `ast.policy` in tests with `ast.with_rego_v1`
- Fix docs that used `=` for assignment rather than `:=`

Fixes #901

Signed-off-by: Anders Eknert <[email protected]>
charlieegan3 pushed a commit that referenced this issue Jul 8, 2024
This was due to an unfortunate combination of trying to be lenient
about `coll[_]` used in the position of a function arg (as that's not
*directly* replaceable by `some .. in` **but** not excluding operators
like `:=` from functions (where it _should_ be replaced by `some .. in`)
**and** many tests for this rule missing to provide the built-in functions
as a mocked dependency.

Will need to think some about how to best avoid this to happen again.

Also:
- Replace `ast.policy` in tests with `ast.with_rego_v1`
- Fix docs that used `=` for assignment rather than `:=`

Fixes #901

Signed-off-by: Anders Eknert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant