DeFiCh/wallet

View on GitHub

Showing 335 of 335 total issues

Function WalletAccordion has 108 lines of code (exceeds 100 allowed). Consider refactoring.
Open

export function WalletAccordion(props: AccordionProps): JSX.Element {
  const { isLight } = useThemeContext();
  const [activeSections, setActiveSections] = useState<number[] | string[]>(
    props.activeSections ?? []
  );
Severity: Major
Found in mobile-app/app/components/WalletAccordion.tsx - About 1 hr to fix

    Function VaultIdSection has 108 lines of code (exceeds 100 allowed). Consider refactoring.
    Open

    function VaultIdSection(props: { vault: LoanVaultActive }): JSX.Element {
      const { vault } = props;
      const colRatio = new BigNumber(vault.informativeRatio);
      const minColRatio = new BigNumber(vault.loanScheme.minColRatio);
      const totalLoanAmount = new BigNumber(vault.loanValue);

      Function TokenSummary has 108 lines of code (exceeds 100 allowed). Consider refactoring.
      Open

      function TokenSummary(props: {
        token: WalletToken;
        border?: boolean;
        usdAmount: BigNumber;
        isEvmDomain?: boolean;

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

                  <PoolPairInfoLine
                    label={translate(
                      "screens/DexScreen",
                      `${type === "available" ? "Pooled" : "Your shared"} {{symbol}}`,
                      { symbol: pair.tokenA.displaySymbol }
        mobile-app/app/screens/AppNavigator/screens/Dex/components/PoolPairCards/InfoSection.tsx on lines 70..86

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

        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

                  <PoolPairInfoLine
                    label={translate(
                      "screens/DexScreen",
                      `${type === "available" ? "Pooled" : "Your shared"} {{symbol}}`,
                      { symbol: pair.tokenB.displaySymbol }
        mobile-app/app/screens/AppNavigator/screens/Dex/components/PoolPairCards/InfoSection.tsx on lines 53..69

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

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

        function SummaryDetails(props: {
          addressLabel: string | null;
          address: string | null;
        }): JSX.Element {
          const { network } = useNetworkContext();

          Function RemoveLiquidityConfirmScreen has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export function RemoveLiquidityConfirmScreen({ route }: Props): JSX.Element {
            const {
              pair,
              pairInfo,
              amount,

          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 useValidCollateralRatio has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export function useValidCollateralRatio(
            collateralAmounts: LoanVaultTokenAmount[],
            totalCollateralVaultValue: BigNumber,
            loanValue: BigNumber,
            collateralTokenId?: 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

          Function BrowseAuctions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export function BrowseAuctions({
            batches,
            filteredAuctionBatches,
            showSearchInput,
            searchString,

          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 ActionButton has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function ActionButton(props: ActionButtonsProps): JSX.Element {
            const DFIIcon = getNativeIcon("DFIlogo");
            const { isLight } = useThemeContext();
            return (
              <View style={tailwind("items-center")}>

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

          export function FeatureFlagProvider(
            props: React.PropsWithChildren<any>,
          ): JSX.Element | null {
            const { network } = useNetworkContext();
            const { url, isCustomUrl } = useServiceProviderContext();
          Severity: Major
          Found in mobile-app/app/contexts/FeatureFlagContext.tsx - About 1 hr to fix

            Function BottomSheetModal has 104 lines of code (exceeds 100 allowed). Consider refactoring.
            Open

            export function BottomSheetModal(props: Props): JSX.Element {
              const bottomSheetModalRef = useRef<Modal>(null);
              const { dismiss } = useBottomSheetModal();
              const { isLight } = useThemeContext();
              const {
            Severity: Major
            Found in mobile-app/app/components/BottomSheetModal.tsx - About 1 hr to fix

              Function CollateralizationRatioDisplay has 103 lines of code (exceeds 100 allowed). Consider refactoring.
              Open

              export function CollateralizationRatioDisplay(
                props: CollateralizationRatioDisplayProps
              ): JSX.Element {
                const { isLight } = useThemeContext();
                const atRiskThresholdMultiplier = 1.5;

                Function useEvmTokenBalances has 103 lines of code (exceeds 100 allowed). Consider refactoring.
                Open

                export function useEvmTokenBalances(): { evmTokens: WalletToken[] } {
                  const { evmAddress } = useWalletContext();
                  const [evmTokens, setEvmTokens] = useState<WalletToken[]>([]);
                  const [allTokensWithAddress, setAllTokensWithAddress] =
                    useState<AssociatedToken>({});

                  Function StepTwo has 103 lines of code (exceeds 100 allowed). Consider refactoring.
                  Open

                  function StepTwo(): JSX.Element {
                    const logger = useLogger();
                    const { isLight } = useThemeContext();
                    const { address } = useWalletContext();
                    const [showToast, setShowToast] = useState(false);

                    Function FeatureFlagScreen has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function FeatureFlagScreen(): JSX.Element {
                      const { featureFlags, enabledFeatures, updateEnabledFeatures } =
                        useFeatureFlagContext();
                      const [betaFeatures, setBetaFeatures] = useState<BetaFeaturesI[]>([]);
                    
                    

                    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 ThemedIcon has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function ThemedIcon(props: ThemedIconProps): JSX.Element {
                      const { isLight } = useThemeContext();
                      const {
                        style,
                        iconType,
                    Severity: Minor
                    Found in mobile-app/app/components/themed/ThemedIcon.tsx - About 1 hr 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 PinConfirmation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function PinConfirmation({ route }: Props): JSX.Element {
                      const navigation = useNavigation<NavigationProp<WalletParamList>>();
                      const logger = useLogger();
                      const [isComplete, setIsComplete] = useState<boolean>(false); // To complete the last stepper node when pin is verified.
                      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 PlaygroundStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function PlaygroundStatus({
                      online,
                      error,
                      loading,
                      offline,

                    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 SubmitButtonGroup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function SubmitButtonGroup({
                      buttonStyle,
                      isDisabled,
                      isCancelDisabled,
                      displayCancelBtn,
                    Severity: Minor
                    Found in mobile-app/app/components/SubmitButtonGroup.tsx - About 1 hr 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

                    Severity
                    Category
                    Status
                    Source
                    Language