Skip to content

Rule: redundant-incremental-definition #1523

@anderseknert

Description

@anderseknert

Another issue I saw in a policy in the wild today is where one definition of an incremental rule is essentially dead code, due to a common condition that would be met by the least complex definition in both rules. Extremely simplified:

allow if "admin" in input.user.roles

alow if {
    "admin" in input.user.roles
    endswith(input.user.email, "@acmecorp.com") # this is pointless
}

The second rule definition is of course pointless in this case, as the first condition of both rules is the same, and there's no reason to evaluate the email address of the user if they're an admin.

There's probably a million things for where this could be true but we can't easily find using only static analysis. That's fine. Just covering the easy/obvious cases is still better than no coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/bugsruleIssues related to new or existing linter rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions