Skip to content
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

fix: Replace cloneDeep with klona #12936 #34477

Closed
wants to merge 4 commits into from

Conversation

JaiZemoso
Copy link

@JaiZemoso JaiZemoso commented Jun 26, 2024

Description

Fixes #12936
or
Issue URL [Issue URL]( https://github.com/appsmithorg/appsmith/issues/12936)

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Refactor
    • Improved the performance and efficiency of the application by replacing lodash.cloneDeep with klona for deep cloning objects across various components and utilities.

These changes enhance object copying mechanisms, potentially reducing memory usage and improving application speed without altering the existing functionality from the end-user perspective.

@JaiZemoso JaiZemoso requested a review from a team as a code owner June 26, 2024 06:09
@JaiZemoso JaiZemoso requested review from a team and marks0351 and removed request for a team June 26, 2024 06:09
Copy link
Contributor

coderabbitai bot commented Jun 26, 2024

Walkthrough

The primary change involves replacing the cloneDeep function from the lodash library with the klona function across multiple files in a TypeScript-based project. This change aims to improve performance and efficiency in deep cloning operations throughout the application, affecting various components, sagas, reducers, and utilities dealing with object manipulation and data handling.

Changes

File Path Change Summary
.../migrate/migrations/009-table-widget-property-pane-migration.ts Replaced lodash/cloneDeep with klona for deep cloning objects.
.../src/layoutSystems/anvil/utils/paste/utils.ts Switched from cloneDeep to klona for deep copying objects during widget operations.
.../src/pages/Editor/FirstTimeUserOnboarding/testUtils.ts Updated to use klona instead of lodash for deep cloning in getStore function.
.../src/reducers/uiReducers/appCollabReducer.ts Replaced cloneDeep with klona for cloning pointerData.
.../src/reflow/reflowUtils.ts Changed deep cloning in getModifiedOccupiedSpacesMap function from cloneDeep to klona.
.../src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts Replaced cloneDeep with klona for deep copying widget properties.
.../src/sagas/CanvasSagas/DraggingCanvasSagas.ts Replaced cloneDeep with klona for copying widget data in moveAndUpdateWidgets function.
.../src/sagas/WidgetOperationSagas.tsx Switched to klona for various deep cloning operations in widget-related sagas.
.../src/sagas/WidgetOperationUtils.ts Introduced klona for deep cloning in functions handling parent widgets and filtering selected widgets.
.../src/transformers/RestActionTransformer.ts Replaced cloneDeep with klona in transformRestAction function.
.../src/utils/WidgetMigrationUtils.test.ts Changed to use klona for deep cloning in DSL tree structure tests.
.../src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx Used klona instead of cloneDeep for handling event objects.
.../src/widgets/ChartWidget/component/helpers.ts Switched to klona for cloning in parseOnDataPointClickForCustomEChart function.
.../src/widgets/JSONFormWidget/widget/propertyConfig/properties/common.ts Replaced lodash.cloneDeep with klona for deep cloning in JSON form widget.
.../src/widgets/ListWidget/widget/index.tsx Replaced cloneDeep with klona and switched to lodashToString for string operations.
.../src/widgets/TableWidget/widget/index.tsx Changed to use klona for deep cloning in TableWidget class.
.../src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx Replaced cloneDeep with klona for updating filters in TableFilterPaneContent component.
.../src/widgets/TabsMigrator/widget/index.tsx Used klona instead of cloneDeep for deep cloning in TabsMigratorWidget component.

Poem

In the land of code where widgets roam,
We swapped the clone, no longer with foam.
Klona came to save the day,
Swift and light in every way.
A rabbit cheers with a joyful hop,
For deep clones now, just a drop!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range and nitpick comments (22)
app/client/src/reducers/uiReducers/appCollabReducer.ts (1)

Line range hint 41-47: Check the variable name in the return statement.

The variable clonedPointerData should be pointerData in the return statement to reflect the updated state correctly.

-      clonedPointerData,
+      pointerData: clonedPointerData,
app/client/src/widgets/ChartWidget/component/helpers.ts (1)

Line range hint 90-92: Consider simplifying control flow.

The static analysis tool suggests removing unnecessary else clauses. This can simplify the control flow and improve code readability.

- else {
-   return {};
- }

Also applies to: 122-126, 124-126

app/client/src/transformers/RestActionTransformer.ts (1)

Line range hint 39-39: Optimize performance and simplify code.

Replace the delete operator with undefined assignment for better performance and use optional chaining to simplify the code.

- delete action.actionConfiguration.body;
+ action.actionConfiguration.body = undefined;

- if (action.actionConfiguration.queryParameters &&
+ if (action.actionConfiguration.queryParameters?.length) {

Also applies to: 44-45

app/client/packages/dsl/src/migrate/migrations/009-table-widget-property-pane-migration.ts (1)

Line range hint 70-70: Optimization suggestions from static analysis.

Consider implementing optional chaining and simplifying the ternary operation as suggested by static analysis to improve code clarity and reduce complexity.

- if (dynamicBindingPathList?.findIndex((item: { key: string }) => item.key !== "tableData"))
+ if (dynamicBindingPathList?.findIndex((item: { key: string }) => item.key !== "table

- isVisible: hiddenColumns.includes(accessor) ? false : true,
+ isVisible: !hiddenColumns.includes(accessor),

Also applies to: 83-83, 103-103, 109-109, 116-116

app/client/src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx (1)

Line range hint 106-106: Recommendation to replace hasOwnProperty with Object.hasOwn.

- if (!config || !config.hasOwnProperty("options")) {
+ if (!config || !Object.hasOwn(config, "options")) {

Replacing hasOwnProperty with Object.hasOwn is recommended for improved safety and compatibility with prototypes.

app/client/src/widgets/TabsMigrator/widget/index.tsx (1)

Line range hint 29-29: Performance and code quality improvements.

Consider replacing the delete operator with undefined assignments and implementing optional chaining as suggested by static analysis to improve performance and reduce complexity.

- delete currentDSL.tabs;
+ currentDSL.tabs = undefined;

- if (currentDSL.children && currentDSL.children.length) {
+ if (currentDSL.children?.length) {

Also, avoid using the spread syntax on accumulators as it can lead to performance issues.

- obj = {
-   ...obj,
-   [tab.id]: {
-     ...tab,
-     isVisible: tab.isVisible === undefined ? true : tab.isVisible,
-     index,
-   },
- };
+ obj[tab.id] = {
+   ...tab,
+   isVisible: tab.isVisible === undefined ? true : tab.isVisible,
+   index,
+ };

Also applies to: 32-32, 101-101, 108-108, 111-111, 89-89

app/client/src/utils/migrations/TableWidget.ts (1)

Line range hint 33-33: Replace hasOwnProperty with Object.hasOwn.

Using Object.hasOwn is safer and recommended to avoid potential issues with the prototype chain.

- if (child.hasOwnProperty("isSortable")) {
+ if (Object.hasOwn(child, "isSortable")) {

Apply similar changes to all other instances where hasOwnProperty is used.

Also applies to: 566-566, 630-630, 689-689, 709-709, 732-732, 782-782

app/client/src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts (1)

Line range hint 757-757: Remove Redundant Catch Block

The catch block at this line is redundant as it only rethrows the error without handling it. Removing this block can simplify the error handling flow.

-  } catch (error) {
-    throw error;
-  }
app/client/src/widgets/ListWidget/widget/index.tsx (2)

Line range hint 1426-1426: Replace isNaN with Number.isNaN for safer type checking.

The use of isNaN can lead to unexpected type coercion. Using Number.isNaN provides a more reliable check.

- if (isNaN(templateHeight) || templateHeight > componentHeight - 45) {
+ if (Number.isNaN(templateHeight) || templateHeight > componentHeight - 45) {

Line range hint 1397-1397: Provide a valid value for the href attribute in the anchor tag.

The href attribute should contain a valid URL to improve accessibility and ensure proper navigation.

- <a className=".modifier" href="#">
+ <a className=".modifier" href="/desired-path">
app/client/src/widgets/TableWidget/widget/index.tsx (4)

Line range hint 488-489: Suggestion: Use optional chaining for better safety and readability.

Consider using optional chaining to simplify the access to nested properties and improve code safety.

- if (columnProperties && columnProperties.hasOwnProperty("boxShadowColor") ...
+ if (columnProperties?.hasOwnProperty("boxShadowColor") ...

Line range hint 531-531: Replace hasOwnProperty with Object.hasOwn.

Using Object.hasOwn() is recommended over hasOwnProperty for checking property existence as it is safer and part of the latest JavaScript standards.

- if (columnProperties.hasOwnProperty("boxShadowColor") ...
+ if (Object.hasOwn(columnProperties, "boxShadowColor") ...

Also applies to: 532-532


Line range hint 576-665: Remove unnecessary else clauses.

These else clauses are redundant and can be omitted to improve code readability and reduce complexity.

- else {
-   ...
- }

Also applies to: 590-665, 606-665, 629-665, 654-665


Line range hint 722-722: Wrap declarations in switch cases in a block.

To prevent scope leakage, wrap the declarations within each switch case in a block.

case ColumnTypes.DATE:
+ {
  let isValidDate = true;
  ...
+ }

Also applies to: 723-725, 726-726, 764-769

app/client/src/sagas/WidgetOperationUtils.ts (3)

Line range hint 104-105: Refactor to use optional chaining for better safety and readability.

Consider using optional chaining to simplify access to nested properties and enhance code safety.

- let root = _.get(widgets, `${widget.parentId}`);
+ let root = widgets?.[widget.parentId];

Also applies to: 134-134, 304-304, 398-398, 441-442, 504-505, 801-801, 1480-1480, 1537-1537, 1631-1631, 1640-1640


Line range hint 306-306: Replace hasOwnProperty with Object.hasOwn for safer property checks.

Using Object.hasOwn instead of hasOwnProperty directly on objects is safer and recommended by modern JavaScript practices.

- if (children.hasOwnProperty(childIndex)) {
+ if (Object.hasOwn(children, childIndex)) {

Also applies to: 400-400, 1713-1713


Line range hint 809-818: Remove unnecessary else clauses to simplify control flow.

Omitting unnecessary else clauses can simplify the logic and improve code readability.

- else {
-   // logic here
- }

Also applies to: 922-922, 1719-1729, 1722-1729, 1730-1733

app/client/src/sagas/WidgetOperationSagas.tsx (3)

Line range hint 360-365: Consider removing unnecessary else clauses.

Based on static analysis, several else clauses are redundant as the preceding branches terminate early. Simplifying these constructs can improve readability and reduce nesting.

- else {
-   // code
- }

Also applies to: 415-420, 480-484


Line range hint 1714-1714: Avoid using the delete operator.

The delete operator is used which can negatively impact performance due to deoptimizations in JavaScript engines. Consider alternatives like setting the property to undefined or restructuring the object without the property.

- delete obj[property];
+ obj[property] = undefined;

Line range hint 804-804: Optimize the use of spread syntax in accumulators.

Using spread syntax in accumulators can lead to quadratic time complexity. Consider using methods that modify the accumulator directly.

- const result = [...accumulator, newItem];
+ accumulator.push(newItem);
app/client/src/reflow/reflowUtils.ts (2)

Line range hint 347-347: Refactor to use optional chaining.

Consider refactoring the code to use optional chaining for better readability and safety. This would prevent potential runtime errors when accessing properties on undefined objects.

- if (prevMovementMap && prevMovementMap[collidingSpace.id] && prevMovementMap[collidingSpace.id][movementDirectionAccessor])
+ if (prevMovementMap?.[collidingSpace.id]?.[movementDirectionAccessor])

Also applies to: 352-352, 359-360, 370-374, 588-589, 612-613, 818-818, 1436-1436, 1438-1438, 1488-1489, 1492-1492, 1555-1555, 1558-1558


Line range hint 852-854: Remove unnecessary else clauses.

The code can be simplified by removing unnecessary else clauses, which are redundant due to previous branches that break early or return values. This will enhance the readability and maintainability of the code.

- if (condition) {
-   return value;
- } else {
-   // other code
- }
+ if (condition) {
+   return value;
+ }
+ // other code

Also applies to: 887-899, 889-899, 894-899, 903-915, 905-915, 910-915

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 854d3f0 and fb151ee.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (20)
  • app/client/packages/dsl/src/migrate/migrations/009-table-widget-property-pane-migration.ts (2 hunks)
  • app/client/src/layoutSystems/anvil/utils/paste/utils.ts (3 hunks)
  • app/client/src/pages/Editor/FirstTimeUserOnboarding/testUtils.ts (2 hunks)
  • app/client/src/reducers/uiReducers/appCollabReducer.ts (2 hunks)
  • app/client/src/reflow/reflowUtils.ts (2 hunks)
  • app/client/src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts (2 hunks)
  • app/client/src/sagas/BuildingBlockSagas/tests/PasteBuildingBlockWidgetSaga.test.ts (2 hunks)
  • app/client/src/sagas/CanvasSagas/DraggingCanvasSagas.ts (2 hunks)
  • app/client/src/sagas/WidgetOperationSagas.tsx (6 hunks)
  • app/client/src/sagas/WidgetOperationUtils.ts (3 hunks)
  • app/client/src/transformers/RestActionTransformer.ts (1 hunks)
  • app/client/src/utils/WidgetMigrationUtils.test.ts (2 hunks)
  • app/client/src/utils/migrations/TableWidget.ts (2 hunks)
  • app/client/src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx (3 hunks)
  • app/client/src/widgets/ChartWidget/component/helpers.ts (2 hunks)
  • app/client/src/widgets/JSONFormWidget/widget/propertyConfig/properties/common.ts (2 hunks)
  • app/client/src/widgets/ListWidget/widget/index.tsx (3 hunks)
  • app/client/src/widgets/TableWidget/widget/index.tsx (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx (3 hunks)
  • app/client/src/widgets/TabsMigrator/widget/index.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • app/client/src/pages/Editor/FirstTimeUserOnboarding/testUtils.ts
  • app/client/src/sagas/CanvasSagas/DraggingCanvasSagas.ts
Additional context used
Biome
app/client/src/widgets/ChartWidget/component/helpers.ts

[error] 90-92: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 122-126: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 124-126: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

app/client/src/transformers/RestActionTransformer.ts

[error] 39-39: Avoid the delete operator which can impact performance. (lint/performance/noDelete)

Unsafe fix: Use an undefined assignment instead.


[error] 44-45: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

app/client/packages/dsl/src/migrate/migrations/009-table-widget-property-pane-migration.ts

[error] 70-70: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 83-83: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 103-103: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with


[error] 109-109: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 116-116: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

app/client/src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx

[error] 106-106: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

app/client/src/widgets/TabsMigrator/widget/index.tsx

[error] 29-29: Avoid the delete operator which can impact performance. (lint/performance/noDelete)

Unsafe fix: Use an undefined assignment instead.


[error] 32-32: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 101-101: Avoid the delete operator which can impact performance. (lint/performance/noDelete)

Unsafe fix: Use an undefined assignment instead.


[error] 108-108: Avoid the delete operator which can impact performance. (lint/performance/noDelete)

Unsafe fix: Use an undefined assignment instead.


[error] 111-111: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 89-89: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

app/client/src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx

[error] 199-199: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

app/client/src/utils/migrations/TableWidget.ts

[error] 33-33: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 84-84: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 97-97: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 117-117: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with


[error] 123-123: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 130-130: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 342-343: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 566-566: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 630-630: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 689-689: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 709-709: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 732-732: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 782-782: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

app/client/src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts

[error] 757-757: The catch clause that only rethrows the original error is redundant. (lint/complexity/noUselessCatch)

These unnecessary catch clauses can be confusing. It is recommended to remove them.

app/client/src/widgets/ListWidget/widget/index.tsx

[error] 44-44: Do not shadow the global "toString" property. (lint/suspicious/noShadowRestrictedNames)

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.


[error] 1397-1397: Provide a valid value for the attribute href. (lint/a11y/useValidAnchor)

The href attribute should be a valid a URL
Check this thorough explanation to better understand the context.


[error] 47-47: Shouldn't redeclare 'klona'. Consider to delete it or rename it. (lint/suspicious/noRedeclare)

'klona' is defined here:


[error] 1426-1426: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

app/client/src/widgets/TableWidget/widget/index.tsx

[error] 488-489: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 531-531: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 532-532: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 576-665: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 590-665: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 606-665: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 629-665: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 654-665: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 722-722: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.


[error] 723-725: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.


[error] 726-726: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.


[error] 764-769: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.


[error] 896-897: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

app/client/src/sagas/WidgetOperationUtils.ts

[error] 104-105: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 134-134: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 304-304: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 306-306: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 398-398: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 400-400: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 441-442: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 504-505: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 801-801: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 809-818: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 922-922: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 1480-1480: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1537-1537: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1631-1631: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1640-1640: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1713-1713: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.


[error] 1719-1729: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 1722-1729: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 1730-1733: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

app/client/src/sagas/WidgetOperationSagas.tsx

[error] 360-365: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 415-420: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 480-484: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 1714-1714: Avoid the delete operator which can impact performance. (lint/performance/noDelete)


[error] 804-804: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

app/client/src/reflow/reflowUtils.ts

[error] 347-347: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 352-352: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 359-360: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 370-374: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 588-589: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 612-613: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 818-818: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 852-854: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 887-899: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 889-899: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 894-899: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 903-915: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 905-915: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 910-915: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 1436-1436: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1438-1438: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1488-1489: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1492-1492: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1555-1555: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 1558-1558: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (33)
app/client/src/utils/WidgetMigrationUtils.test.ts (1)

33-33: Replacement of cloneDeep with klona looks good.

This change is part of the PR objectives to replace cloneDeep with klona. Ensure that klona correctly replicates the deep cloning functionality needed in this test scenario.

app/client/src/reducers/uiReducers/appCollabReducer.ts (1)

5-5: Import of klona is correctly placed.

This change is consistent with the PR’s goal of replacing cloneDeep with klona.

app/client/src/widgets/ChartWidget/component/helpers.ts (2)

3-4: Import statements are updated correctly.

The replacement of cloneDeep with klona is consistent with the PR’s objectives.


26-26: Replacement of cloneDeep with klona in event data processing.

Ensure that klona adequately replicates the deep cloning functionality required for handling chart event data.

app/client/src/transformers/RestActionTransformer.ts (2)

8-8: Import of klona is correctly placed.

This change aligns with the PR’s objectives to replace cloneDeep with klona.


15-15: Replacement of cloneDeep with klona for cloning API action data.

Confirm that klona provides the necessary functionality for cloning API data without losing any properties or causing side effects.

Verification successful

Replacement of cloneDeep with klona for cloning API action data is appropriate.

The extensive usage of klona across the codebase, including in numerous test cases, and the comments indicating its performance benefits and deep cloning capabilities, confirm that klona provides the necessary functionality for cloning API data without losing properties or causing side effects.

  • Examples of klona usage in tests:
    • app/client/src/sagas/PasteWidgetUtils/PasteWidgetUtils.test.ts
    • app/client/src/utils/klona.test.ts
    • app/client/src/widgets/JSONFormWidget/schemaParser.test.ts
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any issues reported with `klona` in similar scenarios.
rg --type markdown 'klona issues'

Length of output: 35



Script:

#!/bin/bash
# Search for all instances of `klona` usage in the codebase.
rg 'klona'

# Search for all instances of `cloneDeep` usage in the codebase.
rg 'cloneDeep'

# Search for test cases involving cloning API action data.
rg --type js 'klona' -g '*test*'

Length of output: 47934

app/client/src/sagas/BuildingBlockSagas/tests/PasteBuildingBlockWidgetSaga.test.ts (2)

19-19: Import of klona is correctly placed.

This change is consistent with the PR’s goal of replacing cloneDeep with klona.


129-129: Use of klona in test saga for cloning widget lists.

Ensure that klona correctly replicates the deep cloning functionality needed in this test scenario.

app/client/src/layoutSystems/anvil/utils/paste/utils.ts (3)

3-3: Import statement for klona is correct.

The import statement for klona is correctly formatted and placed among other import statements, ensuring clarity and maintainability.


46-46: Replacement of cloneDeep with klona in widget cloning.

The change from cloneDeep to klona for cloning widget properties is correctly implemented. Ensure that klona meets all deep cloning needs as per the widget properties' complexity.


77-77: Ensure correct cloning of layout properties.

The replacement of cloneDeep with klona for cloning layout properties within the updateLayoutProps function is correctly implemented. It's crucial to verify that klona accurately clones nested properties if any.

app/client/packages/dsl/src/migrate/migrations/009-table-widget-property-pane-migration.ts (2)

2-2: Import statement for klona is correct.

The import statement for klona is correctly formatted and placed among other import statements, ensuring clarity and maintainability.


28-28: Correct implementation of klona for DSL widget cloning.

The use of klona for cloning DSL widget instances in the migration function is correctly implemented. This ensures that the widget's state is accurately copied during the migration process.

app/client/src/widgets/ChartWidget/component/CustomEChartIFrameComponent.tsx (3)

8-8: Import statement for klona is correct.

The import statement for klona is correctly formatted and placed among other import statements, ensuring clarity and maintainability.


147-147: Correct use of klona for event data cloning in ECharts.

The replacement of cloneDeep with klona for cloning event data in the ECharts component is correctly implemented. This ensures accurate and efficient copying of event data for further processing.


163-163: Correct use of klona for cloning chart configuration.

The use of klona for cloning the chart configuration before modifying it for callback functions is correctly implemented. This ensures that the original configuration is not mutated unintentionally.

app/client/src/widgets/TabsMigrator/widget/index.tsx (2)

8-9: Import statements for lodash and klona are correct.

The import statements for lodash and klona are correctly formatted and placed among other import statements, ensuring clarity and maintainability.


264-264: Correct implementation of klona for props cloning in TabsMigrator.

The use of klona for cloning props in the TabsMigratorWidget component is correctly implemented. This ensures that the props are accurately copied during the migration process.

app/client/src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx (2)

21-21: Import statement for klona is correct.

The import statement for klona is correctly formatted and placed among other import statements, ensuring clarity and maintainability.


214-214: Correct use of klona for cloning filter data.

The replacement of direct array manipulation with klona for cloning filter data in the TableFilterPaneContent component is correctly implemented. This ensures that the filter data is accurately copied before modification, preventing unintended mutations.

Also applies to: 241-241

app/client/src/widgets/JSONFormWidget/widget/propertyConfig/properties/common.ts (2)

69-69: Replacement of cloneDeep with klona looks appropriate.

The usage of klona here is correct and should maintain the intended functionality for deep cloning properties from props.


71-71: Good use of klona for cloning individual schema items.

This ensures that modifications to currentSchemaItem do not affect the original schema object, preserving immutability which is crucial in Redux-like state management.

app/client/src/utils/migrations/TableWidget.ts (1)

44-44: Proper implementation of klona for cloning widget properties.

This change correctly replaces cloneDeep with klona, which is expected to handle deep cloning of widget properties efficiently.

app/client/src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts (2)

10-10: Correct Import of klona

The import statement for klona is correct and follows standard practices.


525-525: Appropriate Replacement of cloneDeep with klona

The usage of klona at line 525 for cloning widget properties is appropriate and should maintain the integrity of deep cloning as required by the application logic.

app/client/src/widgets/TableWidget/widget/index.tsx (1)

253-253: Proper use of klona for deep cloning.

The replacement of cloneDeep with klona is correctly implemented here to avoid direct state mutations, which is a best practice in React development.

app/client/src/sagas/WidgetOperationUtils.ts (3)

35-35: Approved replacement of cloneDeep with klona.

The import and usage of klona for deep cloning in widget operations is a performance improvement. Ensure it is tested thoroughly to verify that deep cloning is performed as expected.


137-137: Approved use of klona in list widget handling.

The use of klona for cloning currentWidget in handleIfParentIsListWidgetWhilePasting function is correct and should help maintain performance with deep cloning operations.


1389-1389: Approved use of klona for state cloning in filterOutSelectedWidgets.

The use of klona to clone the state before modifying it ensures immutability, which is a good practice in Redux Saga operations.

app/client/src/sagas/WidgetOperationSagas.tsx (2)

556-556: Review of klona usage for cloning state.

The replacement of cloneDeep with klona has been correctly implemented in these lines. It's crucial to ensure that klona effectively handles all edge cases previously managed by cloneDeep, especially with complex nested objects and different data types.

Also applies to: 579-579, 615-615, 708-708


1314-1314: Ensure klona properly clones widget properties.

The use of klona here is intended to clone widget properties before modification. Given the complexity of widget properties, verify through additional testing that klona maintains all behaviors, especially for non-primitive values.

app/client/src/reflow/reflowUtils.ts (2)

3-3: Replace cloneDeep with klona is appropriate for deep cloning.
The change from cloneDeep to klona at this import statement is consistent with the PR's objective to enhance performance by using a more efficient deep cloning library.


1424-1424: Ensure correct use of klona for deep cloning.

The replacement of cloneDeep with klona here is consistent with the PR's objective. It's crucial to ensure that klona correctly handles all data structures involved, particularly since this function deals with potentially complex objects in the state management of UI layouts.

Verification successful

Ensure correct use of klona for deep cloning.

The replacement of cloneDeep with klona appears consistent with the PR's objective. The extensive usage of klona across the codebase and the presence of tests verifying its functionality suggest that it correctly handles the deep cloning of complex objects, including nested objects and arrays.

  • app/client/src/reflow/reflowUtils.ts line 1424: if (!prevMovementMap) return klona(occupiedSpacesMap);
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `klona` handles all data structures as expected.
echo "Manual testing required: Ensure klona handles nested objects and arrays correctly in app/client/src/reflow/reflowUtils.ts"

Length of output: 252



Script:

#!/bin/bash
# Search for all instances of `klona` usage in the codebase
rg --word-regexp 'klona' --context 5

# Search for all instances of `cloneDeep` usage in the codebase
rg --word-regexp 'cloneDeep' --context 5

Length of output: 260087

app/client/src/sagas/WidgetOperationSagas.tsx Show resolved Hide resolved
app/client/src/widgets/ListWidget/widget/index.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/ListWidget/widget/index.tsx Outdated Show resolved Hide resolved
@JaiZemoso JaiZemoso changed the title PR for [Task] : Replace cloneDeep with klona #12936 fix: Replace cloneDeep with klona #12936 Jun 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (5)
app/client/src/widgets/ListWidget/widget/index.tsx (2)

Line range hint 1425-1425: Replace isNaN with Number.isNaN for safer type checking.

The use of isNaN can lead to unexpected results due to type coercion. Use Number.isNaN for a more accurate check.

- if (isNaN(templateHeight) || templateHeight > componentHeight - 45) {
+ if (Number.isNaN(templateHeight) || templateHeight > componentHeight - 45) {

Line range hint 1396-1396: Provide a valid href attribute in the anchor tag.

The href attribute should be a valid URL to ensure proper navigation and accessibility standards.

- <a className=".modifier" href="#">
+ <a className=".modifier" href="javascript:void(0);" onClick={(e) => e.preventDefault()}>

This change prevents the default link behavior, making it clear that this is a placeholder or non-navigational link.

app/client/src/sagas/WidgetOperationSagas.tsx (3)

Line range hint 360-365: Consider removing unnecessary else clause.

- else {
+ // Removed unnecessary else clause

The else clause after an early break can be safely removed to simplify the code.


Line range hint 1714-1714: Avoid using the delete operator for performance reasons.

Consider refactoring the code to avoid using the delete operator, which can degrade performance in JavaScript environments.


Line range hint 804-804: Avoid using spread syntax on accumulators.

- const updatedStateWidgets = updatedWidgetsAndActionsToDispatch.reduce(
-   (allWidgets, eachUpdatedWidgetAndActionsToDispatch) => {
-     return {
-       ...allWidgets,
-       [eachUpdatedWidgetAndActionsToDispatch.updatedWidget.widgetId]:
-         eachUpdatedWidgetAndActionsToDispatch.updatedWidget,
-     };
-   },
-   stateWidgets,
- );
+ const updatedStateWidgets = {};
+ updatedWidgetsAndActionsToDispatch.forEach(each => {
+   updatedStateWidgets[each.updatedWidget.widgetId] = each.updatedWidget;
+ });

Replacing the spread syntax in the accumulator with a forEach loop improves performance by avoiding the creation of intermediate copies of the object.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb151ee and f69d7d0.

Files selected for processing (2)
  • app/client/src/sagas/WidgetOperationSagas.tsx (13 hunks)
  • app/client/src/widgets/ListWidget/widget/index.tsx (4 hunks)
Additional context used
Biome
app/client/src/widgets/ListWidget/widget/index.tsx

[error] 1396-1396: Provide a valid value for the attribute href. (lint/a11y/useValidAnchor)

The href attribute should be a valid a URL
Check this thorough explanation to better understand the context.


[error] 1425-1425: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

app/client/src/sagas/WidgetOperationSagas.tsx

[error] 360-365: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 415-420: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 480-484: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 1714-1714: Avoid the delete operator which can impact performance. (lint/performance/noDelete)


[error] 804-804: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

Additional comments not posted (7)
app/client/src/widgets/ListWidget/widget/index.tsx (2)

Line range hint 39-39: Import of klona is correctly implemented.

The import statement import { klona } from 'klona/lite'; correctly replaces the previous cloneDeep usage. This should improve performance as klona/lite is optimized for typical JavaScript object cloning scenarios.


341-341: Correct use of klona in dynamic property updating.

The usage of klona in the function to clone widget properties ensures that each widget instance maintains its own state without unintended reference sharing. This is crucial for correct functionality in reactive UI environments.

app/client/src/sagas/WidgetOperationSagas.tsx (5)

35-36: Approved changes to import statements.

The import of klona from the klona library is correctly replacing cloneDeep from lodash, aligning with the PR's objectives to improve performance.


556-556: Replacement of cloneDeep with klona is correctly implemented in resizeSaga.

The use of klona for cloning widget states in resizeSaga is correctly implemented and should maintain the integrity of the function while potentially improving performance.


589-589: Review the function getDynamicTriggerPathListUpdate for any potential issues.

The logic in getDynamicTriggerPathListUpdate should be carefully reviewed to ensure it correctly handles dynamic trigger paths updates.


615-615: Batch update function uses klona effectively.

The batchUpdateWidgetDynamicPropertySaga function correctly uses klona for cloning state widgets, which is in line with the PR's objectives.


579-579: Check the use of klona in reflowWidgets.

The use of klona in reflowWidgets needs to be carefully verified to ensure it handles the cloning requirements without issues.

@JaiZemoso
Copy link
Author

@marks0351

Can you kindly check this Pull request ?

@marks0351 marks0351 requested review from rishabhrathod01 and removed request for marks0351 June 28, 2024 04:30
@JaiZemoso
Copy link
Author

@rishabhrathod01 can you kindly review this PR ?

@nidhi-nair nidhi-nair removed the request for review from a team June 28, 2024 07:25
@rishabhrathod01
Copy link
Contributor

@JaiZemoso the task is not as simple as the title. We cannot directly replace the library here. Each such replacement will need to be tested either manually or using automation. As this would be quite a huge change hence this task was removed from the Good first issue.

@rishabhrathod01
Copy link
Contributor

@somangshu code where the library is replaced is majorly widgets related. Could you please assign a reviewer from widget team for this PR.

@rishabhrathod01 rishabhrathod01 removed their request for review June 28, 2024 17:50
@somangshu
Copy link
Contributor

somangshu commented Jul 2, 2024

@rishabhrathod01 this is a very large change and hence risky, its not even a GFI. I suggest we dont take it forward.

cc @rajatagrawal what do you think?

@akshayvijayjain
Copy link

@somangshu @rishabhrathod01 @rajatagrawal

Please excuse me jumping in between.

If you see the changes is only one

replace cloneDeep with klona.

both the functions do same thing i.e. create deep clone.

if I ask chatgpt, it also says klona is a drop in replacement for cloneDeep, and we did it over here.

if klona is better and it is a drop-in replacement for cloneDeep, what risk do you see?

@somangshu
Copy link
Contributor

ChatGPT does not understand the context of appsmith repo. It does not know the impact that the library change might have.

AFAIK, we have tried this before and did not succeed at completing it. There were test failures noticed.
Ill let resident technical experts in our team take the final call.

@rishabhrathod01
Copy link
Contributor

@rishabhrathod01 this is a very large change and hence risky, its not even a GFI. I suggest we dont take it forward.

cc @rajatagrawal what do you think?

Yes, i agree. The result from klona and clone of lodash has differences for date objects, regex values and more that we discovered in past. We need to be careful before making such change.

1 similar comment
@rishabhrathod01
Copy link
Contributor

@rishabhrathod01 this is a very large change and hence risky, its not even a GFI. I suggest we dont take it forward.

cc @rajatagrawal what do you think?

Yes, i agree. The result from klona and clone of lodash has differences for date objects, regex values and more that we discovered in past. We need to be careful before making such change.

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Jul 10, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Replace cloneDeep with klona
4 participants