regal icon indicating copy to clipboard operation
regal copied to clipboard

Rule to not use `=`

Open colezlaw opened this issue 3 months ago • 0 comments

As a user, I would like to be warned when I use the = operator in a policy and be reminded that := and == are explicit and clear, whereas = can be ambiguous so that my policies are clearer and more maintainable.

Because Rego rules are immutable, the first time and identifier is seen, the = operator is used for assignment. Once the left hand side has been assigned to, when referred to in the future, = is the equality operator. This simple example from the REPL shows what's going on:

> import rego.v1
> foo = 3
Rule 'foo' defined in package repl. Type 'show' to see rules.
> foo = 4
undefined
> foo = 3
true

I'd like a rule to tell me to use := for assignment and == for equality checks and to not use = because its meaning can be ambiguous.

colezlaw avatar May 16 '24 20:05 colezlaw