-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add query to ensure predicates starting with 'get' return a value #18164
Add query to ensure predicates starting with 'get' return a value #18164
Conversation
85c922f
to
a763dd7
Compare
Co-authored-by: Anders Schack-Mulligen <[email protected]>
5fa40c4
to
a5521b9
Compare
Co-authored-by: Anders Schack-Mulligen <[email protected]>
isGetPredicate(pred) and | ||
not hasReturnType(pred) and | ||
not isAlias(pred) | ||
select pred, "This predicate starts with 'get' but does not return a value." |
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.
This message is slightly inaccurate now 😄
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.
a462ec9 🙈
ql/ql/test/queries/style/ValidatePredicateGetReturns/ValidatePredicateGetReturns.expected
Outdated
Show resolved
Hide resolved
1f3187b
to
a462ec9
Compare
9b9581f
to
a908a44
Compare
… thought they had
a908a44
to
7c1aa84
Compare
/** | ||
* Returns "get" if the predicate name starts with "get", otherwise "as". | ||
*/ | ||
string getPrefix(Predicate pred) { |
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.
There's really no need for this predicate - just replace regexpMatch
with regexpCapture
in isGetPredicate
and add the prefix column to that predicate.
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.
I see, that does make it cleaner!
67745e6
where | ||
isGetPredicate(pred, prefix) and | ||
not hasReturnType(pred) and | ||
not isAlias(pred) |
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.
Should we instead check that whatever it aliases has a return type?
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.
I think that's a very reasonable extension of this query, but I don't mind merging as-is, hence approved.
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.
Is this what you have had in mind 01b62ad ?
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.
Yes, thanks for adding.
…ates lacking a return type. Co-authored-by: asgerf <[email protected]>
01b62ad
to
7db9b7d
Compare
This PR adds a new query to ensure that predicates starting with 'get' actually return a value. It includes the query definition, expected test results, and test cases to validate the functionality.