-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[apex] New Rule: Avoid soql/sosl queries without a where clause or limit statement #635
Comments
# Conflicts: # pmd-apex/src/main/resources/rulesets/apex/ruleset.xml
Right now it's pretty dumb where it won't catch subqueries: Should probably extract subqueries first and count them separately...
Could be an improvement, the rule should be usable and catch most issues already in it's simple state. Subqueries don't happen that often. |
@jsotuyod I recommend to close "feature-request" issues that are not followed by a PR (or ongoing communication) after 2 month. |
I'm closing this as the PR proved the capabilities to parse the SOQL and enforce the rule are very limited. Maybe future versions of Jorje will make this easier, otherwise, we would need something such as #237 along with the PL/SQL grammar. |
@jsotuyod With the new Apex parser, is this request more feasible? |
@dschach not really. The new apex parser parses both SOQL and SOSL queries. But this parse tree is not yet translated into a syntax tree. That would need to be added to Summit AST. Summit AST right now just replaced Jorje and didn't add functionality. The SOQL/SOSL queries are provided as raw strings, so these are currently available in PMD. See e.g. pmd/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java Lines 33 to 43 in 648e2eb
In Summmit AST, see https://github.com/google/summit-ast/blob/b036f6a2544db86064c8fd7adca01075b60ba954/src/main/java/com/google/summit/translation/Translate.kt#L1434-L1442 So, in summary, these are the options:
|
Rule Set: Apex, perfomance
Description:
When working with very large amounts of data, unfiltered SOQL queries can quickly cause governor limit exceptions
Code Sample demonstrating the issue:
The text was updated successfully, but these errors were encountered: