-
Notifications
You must be signed in to change notification settings - Fork 1.7k
QL-for-QL: Add a could-be-cast query #7472
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
Conversation
5e2883f
to
09b2be1
Compare
d0ccfd2
to
c870d87
Compare
c870d87
to
491cc76
Compare
491cc76
to
ad11fec
Compare
I disagree with simplifying the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exists
case catches too much.
I see. Yes, a decent amount of those warning are better as is. I've done two things: 1: Change the severity to 2: Restrict the flagged // old
exists(State state | state = getAState(this, str.length() - 1, str, _) |
epsilonSucc*(state) = Accept(_)
)
// refactored
epsilonSucc*(getAState(this, str.length() - 1, str, _)) = Accept(_) |
I think it's fine to just call it an "exists" in the query name, and then use either "exists" or "any" in the message. In any case, calling it an aggregate when it definitely isn't an aggregate is somewhat problematic, I think. |
There are a couple of those FPs - when the single use is in just one branch of an |
Looking through some more results, I find that I generally agree with the "can replaced with an instanceof expression." suggestions, but I mostly wouldn't change any of the |
So I think we should limit the query to the cases where the entire |
I'll do that, and rewrite the query into a |
58d3d00
to
14d2f5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better! Looking through a bunch of the alerts, they now all look like something I'd want to fix.
Nice 🎉 Can I get a QL-for-QL reviewer to sign off on this? |
Inspired by #5160
I haven't fixed the issues identified by this query.
This query identifies
exists(..)
/any(..)
that can be simplified to a type-cast:exists(Type t | t = foo())
can be simplified tofoo() instanceof Type
.And
any(Type t | t = foo())
can be simplified tofoo().(Type)
.