-
Notifications
You must be signed in to change notification settings - Fork 404
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
chore: Updated lint rule suppression comment #2895
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2895 +/- ##
==========================================
- Coverage 97.39% 97.35% -0.05%
==========================================
Files 310 310
Lines 47512 47512
==========================================
- Hits 46276 46254 -22
- Misses 1236 1258 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
// The lint rule being suppressed here has been evaluated, and it has been | ||
// determined that the regular expression is sufficient for our use case. | ||
// eslint-disable-next-line sonarjs/slow-regex | ||
const match = /^\s*use[^\w`]+([\w$\u0080-\uFFFF]+|`[^`]+`)[\s;]*$/i.exec(sql) |
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.
Am I reading this correctly? It seems as though the regex has changed from the previous commit.
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.
Notice that the second suppressed rule has been removed from suppression.
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'm thinking about the underscore (\w$_\u0080
to \w$\u0080
), which has been in that regex for a long time prior to this change.
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 PR resolves #2859.
I worked on a couple of different algorithms in an attempt to get around the rule violation, but the regular expression is our best option. The simplest algorithm I was able to devise still used regular expressions, but ended up being slower (despite being easier to follow). I have attached my benchmark below.
Benchmark