-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: replace Lodash usage with native JS implementation #31907
base: master
Are you sure you want to change the base?
chore: replace Lodash usage with native JS implementation #31907
Conversation
Signed-off-by: hainenber <[email protected]>
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Fix Detected |
---|---|---|
Unhandled JSON Parse Error ▹ view | ||
Redundant Type Checking ▹ view |
Files scanned
File Path | Reviewed |
---|---|
superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/timeOffset.ts | ✅ |
superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts | ✅ |
superset-frontend/plugins/plugin-chart-echarts/src/utils/treeBuilder.ts | ✅ |
superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx | ✅ |
superset-frontend/src/explore/components/controls/BoundsControl.tsx | ✅ |
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utils.ts | ✅ |
superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts | ✅ |
superset-frontend/src/reduxUtils.ts | ✅ |
superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx | ✅ |
superset-frontend/src/explore/components/controls/ColorSchemeControl/index.tsx | ✅ |
superset-frontend/src/explore/components/DatasourcePanel/index.tsx | ✅ |
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx | ✅ |
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx | ✅ |
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx | ✅ |
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Need a new review? Comment
/korbit-review
on this PR and I'll review your latest changes.Korbit Guide: Usage and Customization
Interacting with Korbit
- You can manually ask Korbit to review your PR using the
/korbit-review
command in a comment at the root of your PR.- You can ask Korbit to generate a new PR description using the
/korbit-generate-pr-description
command in any comment on your PR.- Too many Korbit comments? I can resolve all my comment threads if you use the
/korbit-resolve
command in any comment on your PR.- Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
- Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.
Customizing Korbit
- Check out our docs on how you can make Korbit work best for you and your team.
- Customize Korbit for your organization through the Korbit Console.
Current Korbit Configuration
General Settings
Setting Value Review Schedule Automatic excluding drafts Max Issue Count 10 Automatic PR Descriptions ❌ Issue Categories
Category Enabled Naming ✅ Database Operations ✅ Documentation ✅ Logging ✅ Error Handling ✅ Systems and Environment ✅ Objects and Data Structures ✅ Readability and Maintainability ✅ Asynchronous Processing ✅ Design Patterns ✅ Third-Party Libraries ✅ Performance ✅ Security ✅ Functionality ✅ Feedback and Support
Note
Korbit Pro is free for open source projects 🎉
Looking to add Korbit to your team? Get started with a free 2 week trial here
if (typeof datasource?.templateParams === 'string') { | ||
const p = JSON.parse(datasource.templateParams); |
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.
Unhandled JSON Parse Error
Tell me more
What is the issue?
The code doesn't handle JSON.parse errors which could occur if templateParams contains invalid JSON string.
Why this matters
If templateParams contains malformed JSON, the application will crash when trying to parse it, interrupting the save dataset operation.
Suggested change ∙ Feature Preview
Add try-catch block to handle potential JSON parsing errors:
let templateParams;
if (typeof datasource?.templateParams === 'string') {
try {
const p = JSON.parse(datasource.templateParams);
/* eslint-disable-next-line no-underscore-dangle */
if (p._filters) {
/* eslint-disable-next-line no-underscore-dangle */
delete p._filters;
// eslint-disable-next-line no-param-reassign
templateParams = JSON.stringify(p);
}
} catch (error) {
console.error('Error parsing templateParams:', error);
templateParams = datasource.templateParams;
}
}
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
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.
Not my change though
@@ -76,7 +75,7 @@ export function CustomFrame(props: FrameComponentProps) { | |||
value: string | number, | |||
) { | |||
// only positive values in grainValue controls | |||
if (isInteger(value) && value > 0) { | |||
if (typeof value === 'number' && Number.isInteger(value) && value > 0) { |
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.
Redundant Type Checking
Tell me more
What is the issue?
Multiple type checks are being performed unnecessarily in sequence, with Number.isInteger() already implying the value is a number.
Why this matters
The redundant type checking adds unnecessary computation overhead, especially in frequently executed code paths.
Suggested change ∙ Feature Preview
Simplify the condition to only use Number.isInteger() which inherently checks for number type:
if (Number.isInteger(value) && value > 0)
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
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 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.
LGTM, wondering if we can switch some eslint rules to force more native stuff in place of lodash
SUMMARY
chore: replace Lodash usage with native JS implementation
I noticed these replaceable
lodash
usage in the codebase when refactoring Enzyme-based unit tests to RTL and made a corresponding PR to address them afterwards.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
All CI checks should pass
ADDITIONAL INFORMATION