You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Somewhat similar to the unconditional-assignment rule, and also in the style category. I think it would be good to have Regal help simplify comprehensions where the last expression is a simple assignment to a term variable, and suggest moving the value directly to the comprehension head instead.
Avoid
to_string(ref) :=concat(".", [path | some part in ref
path := part.value
])
Prefer
to_string(ref) :=concat(".", [part.value | some part in ref])
Note that while it's often possible to move a lot of code in that direction, like function calls — I don't think that helps readability at all, and so we should stick to recommend this for simple assignment like the example shown above.
The text was updated successfully, but these errors were encountered:
Renamed from "tail" assignment to "term" assignment, as detecting simple assignment of a term var elsewhere involves the same check more or less, just peformed over all the expressions. So something like this should be flagged just the same:
Avoid
to_string(ref) :=concat(".", [path | some part in ref
path := part.value
part.type =="string"
])
Prefer
to_string(ref) :=concat(".", [part.value | some part in ref
part.type =="string"
])
Flag redundant assignment of simple values that could be used
directly as the comprehension term (or key/value).
Fixes#1073
Signed-off-by: Anders Eknert <anders@styra.com>
Flag redundant assignment of simple values that could be used
directly as the comprehension term (or key/value).
FixesStyraInc#1073
Signed-off-by: Anders Eknert <anders@styra.com>
Somewhat similar to the unconditional-assignment rule, and also in the style category. I think it would be good to have Regal help simplify comprehensions where the last expression is a simple assignment to a term variable, and suggest moving the value directly to the comprehension head instead.
Avoid
Prefer
Note that while it's often possible to move a lot of code in that direction, like function calls — I don't think that helps readability at all, and so we should stick to recommend this for simple assignment like the example shown above.
The text was updated successfully, but these errors were encountered: