Skip to main content

unconditional-assignment

Summary: Unconditional assignment in rule body

Category: Style

Avoid

package policy

full_name := name if {
name := concat(", ", [input.first_name, input.last_name])
}

divide_by_ten(x) := y if {
y := x / 10
}

names contains name if {
name := "Regal"
}

Prefer

package policy

full_name := concat(", ", [input.first_name, input.last_name])

divide_by_ten(x) := x / 10

names contains "Regal"

Rationale​

Rules that return values unconditionally should place the assignment directly in the rule head, as doing so in the rule body adds unnecessary noise.

Configuration Options​

This linter rule provides the following configuration options:

rules:
style:
unconditional-assignment:
# one of "error", "warning", "ignore"
level: error