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
I think the change done in #1978 is based on wrong assumptions and should be undone. The example outlined in #1968 can be expressed as follows:
enumValue{case valueA, valueB(a:Int)}func firstIndexOfValueB(in array:[Value])->Int?{
for case let(index,.valueB) in array.enumerated(){return index
}returnnil}
Maybe the name of the rule is misleading because there is no where keyword in the for-loop. There are two possible solutions:
Undo the change in Fix false positives in for_where with pattern matching #1978 and change the description of the rule to "where clauses or pattern-matching are preferred over a single if inside a for.". The name should probably also be changed but the identifier has to stay the same for compatibility reasons.
Don't undo the change and create another rule to catch only the pattern-matching case
The text was updated successfully, but these errors were encountered:
@marcelofabri I agree that these have similarities but #1977 explicitly talks about unwrapping of optionals with a guard statement which should be autocorrected but I'm talking about pattern matching in general. Maybe it also makes sense to merge #2053 and #1977.
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
stalebot
added
the
wontfix
Issues that became stale and were auto-closed by a bot.
label
Nov 8, 2020
New Issue Checklist
Bug Report
I think the change done in #1978 is based on wrong assumptions and should be undone. The example outlined in #1968 can be expressed as follows:
Maybe the name of the rule is misleading because there is no
where
keyword in the for-loop. There are two possible solutions:for_where
with pattern matching #1978 and change the description of the rule to "where
clauses or pattern-matching are preferred over a singleif
inside afor
.". The name should probably also be changed but the identifier has to stay the same for compatibility reasons.The text was updated successfully, but these errors were encountered: