-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Improve for_where rule #1387
Labels
enhancement
Ideas for improvements of existing features and rules.
Comments
marcelofabri
added
the
enhancement
Ideas for improvements of existing features and rules.
label
Mar 24, 2017
Merged
I found a false positive for this rule as well: for a in [1, 2, 3] {
if a == 1 {
return 0
}
return a
} Here the for a in [1, 2, 3] {
if a == 1 {
return 0
} else {
return a
}
} |
Trying! |
Confirmed! Thanks you beat me to it!! |
This was referenced Mar 29, 2017
That's not a false positive, these are all equivalent: private var allFilesExpanded: Bool {
for index in visibleFileRowIndexes {
if !visibleParts[index].isExpanded {
return false
}
}
return true
} private var allFilesExpanded: Bool {
for index in visibleFileRowIndexes where !visibleParts[index].isExpanded {
return false
}
return true
} and finally: private var allFilesExpanded: Bool {
return visibleFileRowIndexes.allSatisfy { visibleParts[$0].isExpanded }
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the
if
is too complex, it's better to have it instead of awhere
clause.Also, that bug that prevents us to recognize local variables sometimes makes the rule trigger false positives.
The text was updated successfully, but these errors were encountered: