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: walk-no-path #1154

Open
anderseknert opened this issue Oct 1, 2024 · 0 comments
Open

Rule: walk-no-path #1154

anderseknert opened this issue Oct 1, 2024 · 0 comments

Comments

@anderseknert
Copy link
Member

Avoid

allow if {
    # path is bound but never referenced
    walk(users, [path, value])

    value.type == "user"
    value.is_admin == true
}

Prefer

allow if {
    # wildcard used for path
    walk(users, [_, value])

    value.type == "user"
    value.is_admin == true
}

The latter is optimized in the evaluation, as the path does not need to be constructed in each iteration. This saves a ton of allocations when traversing large nodes.

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

No branches or pull requests

1 participant