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

Extend use-in-operator to contains check in partial rule sets (or set values) #943

Open
anderseknert opened this issue Jul 29, 2024 · 0 comments
Labels
enhancement New feature or request rule

Comments

@anderseknert
Copy link
Member

This rule currently flags locations where "foo" := bar[_] can be replaced with "foo" in bar. We should extend this to cover also the case of foo["bar"], when foo is known to be a partial rule or a set value, as using in is reasonably considered more idiomatic there too.

Avoid

package p

import rego.v1

partial contains "foo"

allow if {
    partial["foo"]
    # or
    partial.foo
}

Prefer

package p

import rego.v1

partial contains "foo"

allow if {
    "foo" in partial
}
@anderseknert anderseknert added enhancement New feature or request rule labels Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rule
Projects
None yet
Development

No branches or pull requests

1 participant