DeFiCh/wallet

View on GitHub

Showing 335 of 335 total issues

File DexAddLiquidity.tsx has 642 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { PoolPairData } from "@defichain/whale-api-client/dist/api/poolpairs";
import { NavigationProp, useNavigation } from "@react-navigation/native";
import { StackScreenProps } from "@react-navigation/stack";
import BigNumber from "bignumber.js";
import { useCallback, useEffect, useMemo, useState } from "react";
Severity: Major
Found in mobile-app/app/screens/AppNavigator/screens/Dex/DexAddLiquidity.tsx - About 1 day to fix

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

    export function TextSkeletonLoader(
      props: TextSkeletonLoaderProps
    ): JSX.Element {
      const { isLight } = useThemeContext();
      return (
    Severity: Major
    Found in mobile-app/app/components/TextSkeletonLoader.tsx and 1 other location - About 1 day to fix
    mobile-app/app/components/TextSkeletonLoaderV2.tsx on lines 20..60

    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 386.

    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

    export function TextSkeletonLoaderV2(
      props: TextSkeletonLoaderProps
    ): JSX.Element {
      const { isLight } = useThemeContext();
      return (
    Severity: Major
    Found in mobile-app/app/components/TextSkeletonLoaderV2.tsx and 1 other location - About 1 day to fix
    mobile-app/app/components/TextSkeletonLoader.tsx on lines 20..60

    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 386.

    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

    File PoolPairDetailsScreen.tsx has 622 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { View } from "@components";
    import { NumberRowV2 } from "@components/NumberRowV2";
    import {
      IconName,
      IconType,

      Function TransactionAuthorization has 347 lines of code (exceeds 100 allowed). Consider refactoring.
      Open

      export function TransactionAuthorization(): JSX.Element | null {
        const { data: providerData } = useWalletNodeContext();
        const { clearWallets } = useWalletPersistenceContext();
        const { network } = useNetworkContext();
        const whaleApiClient = useWhaleApiClient();

        File LoanCards.tsx has 602 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
        import {
          ThemedFlashList,
          ThemedIcon,
          ThemedScrollViewV2,

          File AddOrRemoveCollateralForm.tsx has 597 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { BottomSheetWithNavRouteParam } from "@components/BottomSheetWithNav";
          import { Button } from "@components/Button";
          import { InputHelperText } from "@components/InputHelperText";
          import { SymbolIcon } from "@components/SymbolIcon";
          import {

            Function DexScreen has 333 lines of code (exceeds 100 allowed). Consider refactoring.
            Open

            export function DexScreen(): JSX.Element {
              const navigation = useNavigation<NavigationProp<DexParamList>>();
              const [activeTab, setActiveTab] = useState<string>(TabKey.AvailablePoolPair);
              const tokens = useSelector((state: RootState) =>
                tokensSelector(state.wallet)
            Severity: Major
            Found in mobile-app/app/screens/AppNavigator/screens/Dex/DexScreen.tsx - About 1 day to fix

              File SendScreen.tsx has 587 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { useCallback, useEffect, useMemo, useRef, useState } from "react";
              import { Platform, TextInput, View } from "react-native";
              import BigNumber from "bignumber.js";
              import { Controller, useForm } from "react-hook-form";
              import { useSelector } from "react-redux";

                Function AddOrRemoveCollateralScreen has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
                Open

                export function AddOrRemoveCollateralScreen({ route }: Props): JSX.Element {
                  const { vault, collateralItem, collateralTokens, isAdd } = route.params;
                  const [selectedCollateralItem, setSelectedCollateralItem] =
                    useState<CollateralItem>(collateralItem);
                
                

                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

                export function PortfolioSkeletonLoader(
                  props: JSX.IntrinsicAttributes &
                    IContentLoaderProps & { children?: React.ReactNode }
                ): JSX.Element {
                  const { isLight } = useThemeContext();
                mobile-app/app/components/skeletonLoaders/TokenSelectionLoader.tsx on lines 11..42

                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 366.

                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

                export function TokenSelectionLoader(
                  props: JSX.IntrinsicAttributes &
                    IContentLoaderProps & { children?: React.ReactNode }
                ): JSX.Element {
                  const { isLight } = useThemeContext();
                mobile-app/app/components/skeletonLoaders/PortfolioSkeletonLoader.tsx on lines 11..42

                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 366.

                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 WithdrawFutureSwapScreen has 323 lines of code (exceeds 100 allowed). Consider refactoring.
                Open

                export function WithdrawFutureSwapScreen(props: Props): JSX.Element {
                  const {
                    futureSwap: { source, destination },
                    executionBlock,
                  } = props.route.params;

                  Function RemoveLiquidityScreen has 322 lines of code (exceeds 100 allowed). Consider refactoring.
                  Open

                  export function RemoveLiquidityScreen(props: Props): JSX.Element {
                    const logger = useLogger();
                    const client = useWhaleApiClient();
                    const toast = useToast();
                    const [fee, setFee] = useState<BigNumber>(new BigNumber(0.0001));

                    File AddOrEditAddressBookScreen.tsx has 569 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import { MnemonicStorage } from "@api/wallet/mnemonic_storage";
                    import {
                      ThemedIcon,
                      ThemedScrollViewV2,
                      ThemedSectionTitleV2,

                      Function AuctionDetailScreen has 315 lines of code (exceeds 100 allowed). Consider refactoring.
                      Open

                      export function AuctionDetailScreen(
                        props: BatchDetailScreenProps
                      ): JSX.Element {
                        const { batch: batchFromParam, vault } = props.route.params;
                        const [batch, setBatch] = useState<LoanVaultLiquidationBatch>(batchFromParam);

                        Function BottomSheetAddressDetailV2 has 312 lines of code (exceeds 100 allowed). Consider refactoring.
                        Open

                          memo(() => {
                            const { isLight } = useThemeContext();
                            const flatListComponents = {
                              mobile: BottomSheetFlatList,
                              web: ThemedFlatListV2,

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

                          export function VaultSectionTextRow(
                            props: IVaultSectionTextProps
                          ): JSX.Element {
                            return (
                              <View style={tailwind(props.customContainerStyle)}>
                          mobile-app/app/screens/AppNavigator/screens/Loans/components/VaultSectionTextRowV2.tsx on lines 21..66

                          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 354.

                          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

                          export function VaultSectionTextRowV2(
                            props: IVaultSectionTextProps
                          ): JSX.Element {
                            return (
                              <View style={tailwind(props.customContainerStyle)}>
                          mobile-app/app/screens/AppNavigator/screens/Loans/components/VaultSectionTextRow.tsx on lines 21..66

                          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 354.

                          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

                          File TokenDetailScreen.tsx has 559 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import * as React from "react";
                          import { useEffect, useState } from "react";
                          import { Linking, TouchableOpacity } from "react-native";
                          import { tailwind } from "@tailwind";
                          import BigNumber from "bignumber.js";
                            Severity
                            Category
                            Status
                            Source
                            Language