-
Notifications
You must be signed in to change notification settings - Fork 37
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: comprehension-term-assignment
#1073
Labels
Comments
anderseknert
changed the title
Rule:
Rule: Sep 8, 2024
comprehension-tail-assignment
comprehension-term-assignment
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"
]) |
anderseknert
added a commit
that referenced
this issue
Sep 10, 2024
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 <[email protected]>
srenatus
pushed a commit
to srenatus/regal
that referenced
this issue
Oct 1, 2024
Flag redundant assignment of simple values that could be used directly as the comprehension term (or key/value). Fixes StyraInc#1073 Signed-off-by: Anders Eknert <[email protected]>
charlieegan3
pushed a commit
to charlieegan3/regal
that referenced
this issue
Jan 6, 2025
Flag redundant assignment of simple values that could be used directly as the comprehension term (or key/value). Fixes StyraInc#1073 Signed-off-by: Anders Eknert <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: