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

Rule: shadowed-assignment #667

Open
anderseknert opened this issue Apr 20, 2024 · 0 comments
Open

Rule: shadowed-assignment #667

anderseknert opened this issue Apr 20, 2024 · 0 comments

Comments

@anderseknert
Copy link
Member

Shadowing a name from the outer scope is arguably OK, and it's certainly allowed by OPA. But it would be good if there was at least a custom (i.e. optional) rule that flagged this, as it's potentially confusing.

package p

import rego.v1

x := 1

r if {
    x := 4
    x == 4
}

Shadowing a name inside a rule can only be done if inside of a nested body, like a comprehension. Since that type of granularity is complex using the AST alone, it's fine if the first implementation of this rule only considers symbols defined in the package, like rules, functions and imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: TODO
Development

No branches or pull requests

1 participant