-
Notifications
You must be signed in to change notification settings - Fork 193
Closed
Labels
featurea feature request or enhancementa feature request or enhancement
Milestone
Description
Related but I'm not sure it's the same as #2015.
Another type of violation to implicit_assignment_linter()
that I find a bit awkward to refactor looks like:
if (rare_condition1 && rare_condition2 && foo(key <- val)) {
bar(key)
}
Lazy assignment means it's rare that key
is actually assigned, so this refactor is wasteful:
key <- val
if (rare_condition1 && rare_condition2 && foo(key)) {
bar(key)
}
The version that seems preferred gets close to an unnecessary_nested_if()
violation:
if (rare_condition1 && rare_condition2) {
key <- val
if (foo(key)) {
bar(key)
}
}
This increases the indentation vs. the original version; this problem gets worse (possibly combinatorially) if there's more than one such assignment in the same if()
condition.
IINM this is a subset of #2015, but still could be used in different situations. Again there's no such carveout in the style guide, so this usage should be disallowed by default.
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement