polkadot-js/apps

View on GitHub

Showing 600 of 2,040 total issues

File Create.tsx has 425 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright 2017-2024 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { AddressState, CreateOptions, CreateProps, DeriveValidationOutput, PairType, SeedType } from '../types.js';
Severity: Minor
Found in packages/page-accounts/src/modals/Create.tsx - About 6 hrs to fix

    Function getChartResult has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    function getChartResult (totalEligible: BN, isConvictionVote: boolean, info: PalletReferendaReferendumInfoConvictionVotingTally | PalletReferendaReferendumInfoRankedCollectiveTally, track: PalletReferendaTrackInfo, trackGraph: CurveGraph): ChartResultExt[] | null {
      if (totalEligible && isConvictionVote && info.isOngoing) {
        const ongoing = info.asOngoing;
    
        if (ongoing.deciding.isSome) {
    Severity: Minor
    Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 6 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 TxSigned has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    function TxSigned ({ className, currentItem, isQueueSubmit, queueSize, requestAddress, setIsQueueSubmit }: Props): React.ReactElement<Props> | null {
      const { t } = useTranslation();
      const { api } = useApi();
      const { getLedger } = useLedger();
      const { queueSetTxStatus } = useQueue();
    Severity: Minor
    Found in packages/react-signer/src/TxSigned.tsx - About 5 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

    File index.spec.ts has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2017-2024 @polkadot/app-accounts authors & contributors
    // SPDX-License-Identifier: Apache-2.0
    
    /// <reference types="@polkadot/dev-test/globals.d.ts" />
    
    
    Severity: Minor
    Found in packages/page-accounts/src/Accounts/index.spec.ts - About 5 hrs to fix

      File index.tsx has 392 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Copyright 2017-2024 @polkadot/app-accounts authors & contributors
      // SPDX-License-Identifier: Apache-2.0
      
      import type { ActionStatus } from '@polkadot/react-components/Status/types';
      import type { KeyringAddress } from '@polkadot/ui-keyring/types';
      Severity: Minor
      Found in packages/page-accounts/src/Accounts/index.tsx - About 5 hrs to fix

        File index.tsx has 378 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Copyright 2017-2024 @polkadot/app-staking authors & contributors
        // SPDX-License-Identifier: Apache-2.0
        
        import type { DeriveHasIdentity, DeriveStakingOverview } from '@polkadot/api-derive/types';
        import type { StakerState } from '@polkadot/react-hooks/types';
        Severity: Minor
        Found in packages/page-staking-legacy/src/Targets/index.tsx - About 5 hrs to fix

          File index.tsx has 378 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Copyright 2017-2024 @polkadot/app-staking authors & contributors
          // SPDX-License-Identifier: Apache-2.0
          
          import type { DeriveHasIdentity, DeriveStakingOverview } from '@polkadot/api-derive/types';
          import type { StakerState } from '@polkadot/react-hooks/types';
          Severity: Minor
          Found in packages/page-staking/src/Targets/index.tsx - About 5 hrs to fix

            Function Referendum has 125 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function Referendum (props: Props): React.ReactElement<Props> {
              const { t } = useTranslation();
              const bestNumber = useBestNumber();
              const blockInterval = useBlockInterval();
              const { activeIssuance, className = '', palletReferenda, value: { id, info, isConvictionVote, track, trackGraph } } = props;
            Severity: Major
            Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 5 hrs to fix

              Function CrustFiles has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

              function CrustFiles ({ className }: Props): React.ReactElement<Props> {
                const { t } = useTranslation();
                const { queueAction } = useQueue();
                const [showUpMode, setShowUpMode] = useState(false);
                const wFiles = useFiles();
              Severity: Minor
              Found in packages/page-files/src/CrustFiles.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 getInitValue has 117 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function getInitValue (registry: Registry, def: TypeDef): unknown {
                if (def.info === TypeDefInfo.Vec) {
                  return [getInitValue(registry, def.sub as TypeDef)];
                } else if (def.info === TypeDefInfo.Tuple) {
                  return Array.isArray(def.sub)
              Severity: Major
              Found in packages/react-params/src/initValue.ts - About 4 hrs to fix

                File IdentityMain.tsx has 361 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // Copyright 2017-2024 @polkadot/app-accounts authors & contributors
                // SPDX-License-Identifier: Apache-2.0
                
                import type { ApiPromise } from '@polkadot/api';
                import type { Bytes, Data, Option, Struct } from '@polkadot/types';
                Severity: Minor
                Found in packages/page-accounts/src/modals/IdentityMain.tsx - About 4 hrs to fix

                  Function getChartProps has 116 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function getChartProps (bestNumber: BN, blockInterval: BN, chartProps: ChartResultExt[], refId: BN, track: PalletReferendaTrackInfo, t: (key: string, options?: { replace: Record<string, unknown> }) => string): ChartProps[] {
                    const changeXMax = chartProps.reduce((max, { changeX }) =>
                      max === -1 || changeX === -1
                        ? -1
                        : Math.max(max, changeX),
                  Severity: Major
                  Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 4 hrs to fix

                    File index.tsx has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // Copyright 2017-2024 @polkadot/app-staking authors & contributors
                    // SPDX-License-Identifier: Apache-2.0
                    
                    import type { ApiPromise } from '@polkadot/api';
                    import type { DeriveBalancesAll, DeriveStakingAccount } from '@polkadot/api-derive/types';
                    Severity: Minor
                    Found in packages/page-staking-legacy/src/Actions/Account/index.tsx - About 4 hrs to fix

                      File index.tsx has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      // Copyright 2017-2024 @polkadot/app-staking authors & contributors
                      // SPDX-License-Identifier: Apache-2.0
                      
                      import type { ApiPromise } from '@polkadot/api';
                      import type { DeriveBalancesAll, DeriveStakingAccount } from '@polkadot/api-derive/types';
                      Severity: Minor
                      Found in packages/page-staking/src/Actions/Account/index.tsx - About 4 hrs to fix

                        Function getAccountCryptoType has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function getAccountCryptoType (accountId: AccountIdIsh): string {
                          try {
                            const current = accountId
                              ? keyring.getPair(accountId.toString())
                              : null;
                        Severity: Minor
                        Found in packages/react-components/src/util/getAccountCryptoType.ts - 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

                        File Playground.tsx has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // Copyright 2017-2024 @polkadot/app-js authors & contributors
                        // SPDX-License-Identifier: Apache-2.0
                        
                        import type { ApiPromise } from '@polkadot/api';
                        import type { KeyringInstance } from '@polkadot/keyring/types';
                        Severity: Minor
                        Found in packages/page-js/src/Playground.tsx - About 4 hrs to fix

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

                          function Targets ({ className = '', isInElection, nominatedBy, ownStashes, targets: { avgStaked, inflation: { stakedReturn }, lastEra, lowStaked, medianComm, minNominated, minNominatorBond, nominators, totalIssuance, totalStaked, validatorIds, validators }, toggleFavorite, toggleLedger, toggleNominatedBy }: Props): React.ReactElement<Props> {
                            const { t } = useTranslation();
                            const { api } = useApi();
                            const allSlashes = useAvailableSlashes();
                            const daysPayout = useBlocksPerDays(MAX_DAYS);
                          Severity: Minor
                          Found in packages/page-staking-legacy/src/Targets/index.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 Targets has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function Targets ({ className = '', isInElection, nominatedBy, ownStashes, targets: { avgStaked, inflation: { stakedReturn }, lastEra, lowStaked, medianComm, minNominated, minNominatorBond, nominators, totalIssuance, totalStaked, validatorIds, validators }, toggleFavorite, toggleLedger, toggleNominatedBy }: Props): React.ReactElement<Props> {
                            const { t } = useTranslation();
                            const { api } = useApi();
                            const allSlashes = useAvailableSlashes();
                            const daysPayout = useBlocksPerDays(MAX_DAYS);
                          Severity: Minor
                          Found in packages/page-staking/src/Targets/index.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 CardSummary has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function CardSummary ({ children, className = '', label, progress }: Props): React.ReactElement<Props> | null {
                            const value = progress?.value;
                            const total = progress?.total;
                            const left = progress && !isUndefined(value) && !isUndefined(total) && value.gten(0) && total.gtn(0)
                              ? (
                          Severity: Minor
                          Found in packages/react-components/src/CardSummary.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

                          File UploadModal.tsx has 346 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          // Copyright 2017-2024 @polkadot/app-files authors & contributors
                          // SPDX-License-Identifier: Apache-2.0
                          
                          import type { CancelTokenSource } from 'axios';
                          import type { Signer } from '@polkadot/api/types';
                          Severity: Minor
                          Found in packages/page-files/src/UploadModal.tsx - About 4 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language