src/pages/tokens/[id].page.tsx

Summary

Maintainability
C
1 day
Test Coverage

File [id].page.tsx has 419 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { AdaptiveList } from "@components/commons/AdaptiveList";
import { Breadcrumb } from "@components/commons/Breadcrumb";
import { getAssetIcon, getTokenIcon } from "@components/icons/assets/tokens";
import { getWhaleApiClient, useWhaleApiClient } from "@contexts/WhaleContext";
import { TokenData } from "@defichain/whale-api-client/dist/api/tokens";
Severity: Minor
Found in src/pages/tokens/[id].page.tsx - About 6 hrs to fix

    Avoid too many return statements within this function.
    Open

                  return (
                    <AddressLinkExternal
                      url={TOKEN_BACKED_ADDRESS.ETH.cake.link}
                      text={TOKEN_BACKED_ADDRESS.ETH.cake.address}
                      testId="BackingAddress.ETH"
    Severity: Major
    Found in src/pages/tokens/[id].page.tsx - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                    return (
                      <AddressLinkExternal
                        url={TOKEN_BACKED_ADDRESS.DOT.cake.link}
                        text={TOKEN_BACKED_ADDRESS.DOT.cake.address}
                        testId="BackingAddress.DOT"
      Severity: Major
      Found in src/pages/tokens/[id].page.tsx - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                      return (
                        <AddressLinkExternal
                          url={TOKEN_BACKED_ADDRESS.SUI.cake.link}
                          text={TOKEN_BACKED_ADDRESS.SUI.cake.address}
                          testId="BackingAddress.SUI"
        Severity: Major
        Found in src/pages/tokens/[id].page.tsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                        return (
                          <AddressLinkExternal
                            url={TOKEN_BACKED_ADDRESS.SOL.cake.link}
                            text={TOKEN_BACKED_ADDRESS.SOL.cake.address}
                            testId="BackingAddress.SOL"
          Severity: Major
          Found in src/pages/tokens/[id].page.tsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                          return (
                            <AddressLinkExternal
                              url={TOKEN_BACKED_ADDRESS.MATIC.cake.link}
                              text={TOKEN_BACKED_ADDRESS.MATIC.cake.address}
                              testId="BackingAddress.MATIC"
            Severity: Major
            Found in src/pages/tokens/[id].page.tsx - About 30 mins to fix

              Function getServerSideProps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function getServerSideProps(
                context: GetServerSidePropsContext,
              ): Promise<GetServerSidePropsResult<TokenAssetPageProps>> {
                const api = getWhaleApiClient(context);
                const param = context.params?.id?.toString().trim() as string;
              Severity: Minor
              Found in src/pages/tokens/[id].page.tsx - About 25 mins 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

              There are no issues that match your filters.

              Category
              Status