DeFiCh/wallet

View on GitHub

Showing 335 of 335 total issues

Function useLoanPaymentTokenRate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export const useLoanPaymentTokenRate = (props: {
  loanTokenAmountActivePriceInUSD: BigNumber;
  loanToken: {
    id: string;
    displaySymbol: string;

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <ContentLoader
        backgroundColor={isLight ? "#ecebeb" : "#2f2f2f"}
        foregroundColor={isLight ? "#ffffff" : "#4a4a4a"}
        height={88}
        preserveAspectRatio="xMidYMid slice"
mobile-app/app/components/skeletonLoaders/BrowseAuctionsLoader.tsx on lines 25..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 215.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <ContentLoader
        backgroundColor={isLight ? "#ecebeb" : "#2f2f2f"}
        foregroundColor={isLight ? "#ffffff" : "#4a4a4a"}
        speed={2}
        width="100%"
mobile-app/app/components/skeletonLoaders/DexSkeletonLoader.tsx on lines 23..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 215.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function ReceiveScreen has 137 lines of code (exceeds 100 allowed). Consider refactoring.
Open

export function ReceiveScreen(): JSX.Element {
  const logger = useLogger();
  const { address, evmAddress } = useWalletContext();
  const [showToast, setShowToast] = useState(false);
  const toast = useToast();

    Function VaultDetailScreen has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export function VaultDetailScreen({ route, navigation }: Props): JSX.Element {
      const { isLight } = useThemeContext();
      const { vaultId } = route.params;
      const [vault, setVault] = useState<LoanVault>();
      const canUseOperations = useLoanOperations(vault?.state);

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function PlaceBidScreen has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export function PlaceBidScreen(props: Props): JSX.Element {
      const { batch, vault } = props.route.params;
      const tokens = useSelector((state: RootState) =>
        tokensSelector(state.wallet),
      );

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function SendConfirmationScreen has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export function SendConfirmationScreen({ route }: Props): JSX.Element {
      const { domain } = useDomainContext();
      const { address, evmAddress } = useWalletContext();
      const addressLabel = useAddressLabel(address);
      const network = useNetworkContext();

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function TransactionDetailsSection has 132 lines of code (exceeds 100 allowed). Consider refactoring.
    Open

    export function TransactionDetailsSection(
      props: TransactionDetailsProps,
    ): JSX.Element {
      const isEmptyBorrowAmount =
        new BigNumber(props.borrowAmount).isNaN() ||

      Function CreateVaultScreen has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function CreateVaultScreen({ navigation, route }: Props): JSX.Element {
        const dispatch = useAppDispatch();
        const client = useWhaleApiClient();
        const { network } = useNetworkContext();
        const { address } = useWalletContext();

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function WalletStacks has 131 lines of code (exceeds 100 allowed). Consider refactoring.
      Open

        function WalletStacks(): JSX.Element {
          const { width } = Dimensions.get("window");
      
          return (
            <WalletStack.Navigator
      Severity: Major
      Found in mobile-app/app/screens/WalletNavigator/WalletNavigator.tsx - About 2 hrs to fix

        File SwapSummary.tsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Linking, Platform, TouchableOpacity, View } from "react-native";
        import { NumericFormat as NumberFormat } from "react-number-format";
        import BigNumber from "bignumber.js";
        import { tailwind } from "@tailwind";
        import { translate } from "@translations";

          Function NoTokensDark has 131 lines of code (exceeds 100 allowed). Consider refactoring.
          Open

          export function NoTokensDark(): JSX.Element {
            return (
              <Svg width="114" height="97" viewBox="0 0 114 97" fill="none">
                <Path
                  d="M63.2855 95.153C88.4917 95.153 108.927 74.718 108.927 49.4218C108.927 24.1256 88.4017 3.69055 63.2855 3.69055C38.0793 3.69055 17.6443 24.1256 17.6443 49.4218C17.6443 74.718 38.0793 95.153 63.2855 95.153Z"

            File ConfirmPlaceBidScreen.tsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Dispatch, useEffect, useState } from "react";
            import { useSelector } from "react-redux";
            import { NavigationProp, useNavigation } from "@react-navigation/native";
            import { StackScreenProps } from "@react-navigation/stack";
            import { tailwind } from "@tailwind";

              Function TokenSelectionScreen has 130 lines of code (exceeds 100 allowed). Consider refactoring.
              Open

              export function TokenSelectionScreen(): JSX.Element {
                const { isLight } = useThemeContext();
                const { domain } = useDomainContext();
                const navigation = useNavigation<NavigationProp<PortfolioParamList>>();
                const tokens = useSelector((state: RootState) =>

                File QuickBid.tsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { ThemedTextV2, ThemedViewV2 } from "@components/themed";
                import { memo, useEffect, useState } from "react";
                import * as React from "react";
                import { tailwind } from "@tailwind";
                import { SymbolIcon } from "@components/SymbolIcon";

                  File WalletTextInputV2.tsx has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { forwardRef, useCallback, useState } from "react";
                  import {
                    NativeSyntheticEvent,
                    Platform,
                    StyleProp,
                  Severity: Minor
                  Found in mobile-app/app/components/WalletTextInputV2.tsx - About 2 hrs to fix

                    Function NoTokensLight has 128 lines of code (exceeds 100 allowed). Consider refactoring.
                    Open

                    export function NoTokensLight(): JSX.Element {
                      return (
                        <Svg width="114" height="97" viewBox="0 0 114 97" fill="none">
                          <Path
                            d="M63.2855 95.153C88.4917 95.153 108.927 74.718 108.927 49.4218C108.927 24.1256 88.4016 3.69055 63.2855 3.69055C38.0793 3.69055 17.6443 24.1256 17.6443 49.4218C17.6443 74.718 38.0793 95.153 63.2855 95.153Z"

                      Function CFPDetailScreen has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function CFPDetailScreen(): JSX.Element {
                        const logger = useLogger();
                        const dispatch = useAppDispatch();
                        const { isLight } = useThemeContext();
                        const { networkName } = useNetworkContext();

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function AnalyticsProvider has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function AnalyticsProvider(props: PropsWithChildren<any>) {
                        const [isAnalyticsOn, setIsAnalyticsOn] = useState<string>("true");
                        const [hasAnalyticsModalBeenShown, setHasAnalyticsModalBeenShown] =
                          useState<string>("false");
                      
                      
                      Severity: Minor
                      Found in shared/contexts/AnalyticsProvider.tsx - About 2 hrs to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function WalletTransactionCardTextInput has 126 lines of code (exceeds 100 allowed). Consider refactoring.
                      Open

                      >((props: WalletTextInputProps, ref: React.Ref<any>): JSX.Element => {
                        const {
                          title,
                          titleTestID,
                          valid = true,
                      Severity: Major
                      Found in mobile-app/app/components/WalletTransactionCardTextInput.tsx - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language