antoncoding/monarch

View on GitHub

Showing 86 of 95 total issues

Function RebalanceModal has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

export function RebalanceModal({
  groupedPosition,
  isOpen,
  onClose,
  refetch,
Severity: Minor
Found in app/positions/components/RebalanceModal.tsx - About 4 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 PositionsSummaryTable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

export function PositionsSummaryTable({
  marketPositions,
  setShowModal,
  setSelectedPosition,
  refetch,
Severity: Minor
Found in app/positions/components/PositionsSummaryTable.tsx - About 4 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 Markets has 147 lines of code (exceeds 80 allowed). Consider refactoring.
Open

export default function Markets() {
  const { loading, data: rawMarkets } = useMarkets();

  // token keys, aggregated with | for each "ERC20Token" object
  const [selectedCollaterals, setSelectedCollaterals] = useState<string[]>([]);
Severity: Major
Found in app/markets/components/markets.tsx - About 3 hrs to fix

    File FromAndToMarkets.tsx has 317 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import { Input } from '@nextui-org/react';
    import { Pagination } from '@nextui-org/react';
    import Image from 'next/image';
    import { formatUnits } from 'viem';
    Severity: Minor
    Found in app/positions/components/FromAndToMarkets.tsx - About 3 hrs to fix

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

      export function MarketOracleIndicator({
        market,
        isBatched = false,
      }: {
        market: { warningsWithDetail: WarningWithDetail[] };
      Severity: Major
      Found in app/markets/components/RiskIndicator.tsx and 2 other locations - About 3 hrs to fix
      app/markets/components/RiskIndicator.tsx on lines 59..76
      app/markets/components/RiskIndicator.tsx on lines 97..114

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

      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 3 locations. Consider refactoring.
      Open

      export function MarketAssetIndicator({
        market,
        isBatched = false,
      }: {
        market: { warningsWithDetail: WarningWithDetail[] };
      Severity: Major
      Found in app/markets/components/RiskIndicator.tsx and 2 other locations - About 3 hrs to fix
      app/markets/components/RiskIndicator.tsx on lines 78..95
      app/markets/components/RiskIndicator.tsx on lines 97..114

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

      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 3 locations. Consider refactoring.
      Open

      export function MarketDebtIndicator({
        market,
        isBatched = false,
      }: {
        market: { warningsWithDetail: WarningWithDetail[] };
      Severity: Major
      Found in app/markets/components/RiskIndicator.tsx and 2 other locations - About 3 hrs to fix
      app/markets/components/RiskIndicator.tsx on lines 59..76
      app/markets/components/RiskIndicator.tsx on lines 78..95

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

      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 InfoPage has 141 lines of code (exceeds 80 allowed). Consider refactoring.
      Open

      function InfoPage() {
        const [currentSection, setCurrentSection] = useState(0);
        const [isClient, setIsClient] = useState(false);
        const containerRef = useRef<HTMLDivElement>(null);
        const [isTransitioning, setIsTransitioning] = useState(false);
      Severity: Major
      Found in app/info/components/info.tsx - About 3 hrs to fix

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

                <div className="h-12">
                  {' '}
                  {/* Reserve height for pagination */}
                  {toPagination.totalPages > 1 && ( // Only show pagination if more than 1 page
                    <div className="mt-2 flex justify-center">
        Severity: Major
        Found in app/positions/components/FromAndToMarkets.tsx and 1 other location - About 3 hrs to fix
        app/positions/components/FromAndToMarkets.tsx on lines 196..209

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

        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

                <div className="h-12">
                  {' '}
                  {/* Reserve height for pagination */}
                  {fromPagination.totalPages > 1 && ( // Only show pagination if more than 1 page
                    <div className="mt-2 flex justify-center">
        Severity: Major
        Found in app/positions/components/FromAndToMarkets.tsx and 1 other location - About 3 hrs to fix
        app/positions/components/FromAndToMarkets.tsx on lines 311..324

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

        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 types.ts has 307 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        export type MarketPosition = {
          supplyShares: string;
          supplyAssets: string;
          supplyAssetsUsd: number;
          borrowShares: string;
        Severity: Minor
        Found in src/utils/types.ts - About 3 hrs to fix

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

                  <div className={navbarClass}>
                    <div className="flex grow items-center justify-between gap-4">
                      <NavbarTitle />
                      <button
                        type="button"
          Severity: Major
          Found in src/components/layout/header/NavbarMobile.tsx and 1 other location - About 3 hrs to fix
          src/components/layout/header/NavbarMobile.tsx on lines 72..79

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

          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

              <nav className={navbarClass}>
                <div className="flex h-8 grow items-center justify-between gap-4">
                  <NavbarTitle />
                  <button type="button" aria-label="Menu" data-state="closed" onClick={toggleMobileMenuOpen}>
                    <HamburgerMenuIcon width="24" height="24" />
          Severity: Major
          Found in src/components/layout/header/NavbarMobile.tsx and 1 other location - About 3 hrs to fix
          src/components/layout/header/NavbarMobile.tsx on lines 24..36

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

          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 PositionsSummaryTable.tsx has 289 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React, { useMemo, useState, useEffect } from 'react';
          import { Spinner } from '@nextui-org/react';
          import { ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons';
          import Image from 'next/image';
          import { GrRefresh } from 'react-icons/gr';
          Severity: Minor
          Found in app/positions/components/PositionsSummaryTable.tsx - About 2 hrs to fix

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

                          <div className="step-label">
                            <div className="text-lg">{step.label}</div>
                            {currentStep === step.key && step.detail && (
                              <div className="flex items-center gap-2 text-sm text-secondary">
                                {step.detail}
            Severity: Major
            Found in app/markets/components/SupplyProcessModal.tsx and 1 other location - About 2 hrs to fix
            app/positions/components/RebalanceProcessModal.tsx on lines 92..99

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

            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

                            <div className="step-label">
                              <div className="text-lg">{step.label}</div>
                              {currentStep === step.key && step.detail && (
                                <div className="flex items-center gap-2 text-sm text-secondary">
                                  {step.detail}
            Severity: Major
            Found in app/positions/components/RebalanceProcessModal.tsx and 1 other location - About 2 hrs to fix
            app/markets/components/SupplyProcessModal.tsx on lines 83..90

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

            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

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

              const getStepStatus = (stepKey: string) => {
                if (
                  steps.findIndex((step) => step.key === stepKey) <
                  steps.findIndex((step) => step.key === currentStep)
                ) {
            Severity: Major
            Found in app/positions/components/RebalanceProcessModal.tsx and 1 other location - About 2 hrs to fix
            app/markets/components/SupplyProcessModal.tsx on lines 44..55

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

            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

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

              const getStepStatus = (stepKey: string) => {
                if (
                  steps.findIndex((step) => step.key === stepKey) <
                  steps.findIndex((step) => step.key === currentStep)
                ) {
            Severity: Major
            Found in app/markets/components/SupplyProcessModal.tsx and 1 other location - About 2 hrs to fix
            app/positions/components/RebalanceProcessModal.tsx on lines 51..62

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

            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 RebalanceModal.tsx has 267 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useState, useMemo, useCallback } from 'react';
            import {
              Modal,
              ModalContent,
              ModalHeader,
            Severity: Minor
            Found in app/positions/components/RebalanceModal.tsx - About 2 hrs to fix

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

                {
                  mainTitle: 'Liquidity Management',
                  subTitle: 'Keep an eye on illiquid markets',
                  content: (
                    <>
              Severity: Major
              Found in app/info/components/risk.tsx and 2 other locations - About 2 hrs to fix
              app/info/components/risk.tsx on lines 23..37
              app/info/components/risk.tsx on lines 38..50

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

              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

              Severity
              Category
              Status
              Source
              Language