Skip to content
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

first_where false positive when using with Realm Result container #1930

Closed
abagmut opened this issue Nov 1, 2017 · 7 comments
Closed

first_where false positive when using with Realm Result container #1930

abagmut opened this issue Nov 1, 2017 · 7 comments
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@abagmut
Copy link

abagmut commented Nov 1, 2017

// This triggers a violation:
realm?.objects(User.self).filter(NSPredicate(format: "email ==[c] %@", email)).first
@abagmut abagmut changed the title First Where Violation: Prefer using .first(where:) over .filter { }.first in collections. (first_where) first_where false positive when using with Realm collections Nov 1, 2017
@jpsim
Copy link
Collaborator

jpsim commented Nov 1, 2017

Can you please fill out the issue template? It's hard to understand what you're actually reporting.

@abagmut
Copy link
Author

abagmut commented Nov 1, 2017

// This triggers a warning:
realm?.objects(User.self).filter(NSPredicate(format: "email ==[c] %@", email)).first

@abagmut abagmut changed the title first_where false positive when using with Realm collections first_where false positive when using with Realm Result container Nov 1, 2017
@jpsim
Copy link
Collaborator

jpsim commented Nov 1, 2017

Ok, please update the issue template with that so this issue can be understandable for contributors who land here.

@jpsim jpsim added the bug Unexpected and reproducible misbehavior. label Nov 1, 2017
@Jeehut
Copy link
Collaborator

Jeehut commented Feb 12, 2019

@abagmut I can totally understand what this is about and this should of course be fixed. I came across this, too, when using Realm filter functions, here's another example where this triggers but shouldn't:

} else if let pauseToSplit = timeTracker.pauses.filter("beginDate < %@ AND endDate > %@", beginDate, endDate).first {

@sk-
Copy link

sk- commented Apr 23, 2019

Note that the whitelist does not work in cases in which you call a function that returns an NSPredicate.

realm.objects(Model.self).filter(Model.predicate(x: x, y: y)).first

Also note that this issue should also be fixed for the last_where check.

@dschee could you reopen this issue, or should I file a new one?

@jpsim
Copy link
Collaborator

jpsim commented Apr 23, 2019

Please file a new issue to track that.

@jpsim
Copy link
Collaborator

jpsim commented Apr 23, 2019

We may choose to not fix it though since we won't be able to tell if the reference produces an NSPredicate or a closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

4 participants