Skip to content

Conversation

@utarwyn
Copy link
Member

@utarwyn utarwyn commented Mar 20, 2025

Updated the @creedengo/limit-db-query-results (GCI24) rule to only trigger warnings within standard methods used to execute SQL queries. Also added new test cases to verify the updated rule.

We'll be able to add wider support for variables and other libraries, but in the meantime it helps avoid false positives.

Fixes #61

@utarwyn utarwyn added 💉 bug: confirmed Something isn't working 🗃️ rule Impacts a rule labels Mar 20, 2025
@utarwyn utarwyn requested review from Copilot and dedece35 March 20, 2025 23:42
@utarwyn utarwyn self-assigned this Mar 20, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the limit-db-query-results rule to trigger warnings only for SQL queries executed through standard SQL client methods and revises the documentation and tests accordingly.

  • Updated code examples in documentation to illustrate compliant and non-compliant SQL queries.
  • Modified the rule implementation to check if the SQL query is invoked via standard SQL client methods.
  • Updated tests to reflect the new behavior and added changelog entries for clarity.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
eslint-plugin/docs/rules/limit-db-query-results.md Updated documentation examples for non-compliant and compliant code.
eslint-plugin/lib/rules/limit-db-query-results.js Introduced verification for standard SQL client methods usage.
eslint-plugin/tests/lib/rules/limit-db-query-results.js Updated tests to use SQL client methods and validate the rule update.
CHANGELOG.md Added changelog entries for the updated rule.
Comments suppressed due to low confidence (1)

eslint-plugin/lib/rules/limit-db-query-results.js:42

  • The valid test case for 'SELECT TOP 5 * FROM products;' is not handled as a limiting clause. Consider adding 'TOP' to the limitingClauses array to prevent false positives.
const limitingClauses = ["LIMIT", "FETCH FIRST", "WHERE"];

@sonarqubecloud
Copy link

@utarwyn utarwyn merged commit 92820d3 into main Mar 22, 2025
7 checks passed
@utarwyn utarwyn deleted the fix-61-returns-sql-query branch March 22, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💉 bug: confirmed Something isn't working 🗃️ rule Impacts a rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GCI24] Limit the number of returns for a SQL query - False positive

2 participants