-
Notifications
You must be signed in to change notification settings - Fork 16.4k
chore: replace Lodash usage with native JS implementation #31907
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { isInteger } from 'lodash'; | ||
| import { t, customTimeRangeDecode } from '@superset-ui/core'; | ||
| import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; | ||
| import { Col, Row } from 'src/components'; | ||
|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Redundant Type Checking
Tell me moreWhat is the issue?Multiple type checks are being performed unnecessarily in sequence, with Number.isInteger() already implying the value is a number. Why this mattersThe redundant type checking adds unnecessary computation overhead, especially in frequently executed code paths. Suggested change ∙ Feature PreviewSimplify 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| props.onChange( | ||
| customTimeRangeEncode({ | ||
| ...customRange, | ||
|
|
||

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:
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