Skip to content

Commit

Permalink
refactor: [SonarQube] replace || operator with utility func
Browse files Browse the repository at this point in the history
Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.
Nullish coalescing should be preferred typescript:S6606
Software qualities impacted:
Maintainability
  • Loading branch information
tfrg committed Dec 30, 2024
1 parent 9f13bfb commit 34c981a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/web/src/hooks/swap/data/use-swap-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { formatPrice } from "@utils/new-number-utils";
import { matchInputNumber } from "@utils/number-utils";
import { makeDisplayTokenAmount } from "@utils/token-utils";
import { isEmptyObject } from "@utils/validation-utils";
import { nullish } from "@utils/nullish-utils";

import { useTransactionEventStore } from "@hooks/common/use-transaction-event-store";
import { rawBySqrtX96 } from "@utils/swap-utils";
Expand Down Expand Up @@ -949,8 +950,8 @@ export const useSwapHandler = () => {
const broadcastMessage = {
tokenASymbol: tokenA.symbol,
tokenBSymbol: tokenB.symbol,
tokenAAmount: isExactIn ? tokenAAmount : (estimatedAmount || 0).toString(),
tokenBAmount: isExactIn ? (estimatedAmount || 0).toString() : tokenBAmount,
tokenAAmount: isExactIn ? tokenAAmount : nullish.handleFalsy(estimatedAmount, "0"),
tokenBAmount: isExactIn ? nullish.handleFalsy(estimatedAmount, "0") : tokenBAmount,
};

// Handle Wrap and Unwrap
Expand Down

0 comments on commit 34c981a

Please sign in to comment.