polkadot-js/apps

View on GitHub

Showing 600 of 2,052 total issues

File index.tsx has 263 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 { DeriveStakerReward } from '@polkadot/api-derive/types';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
Severity: Minor
Found in packages/page-staking-legacy/src/Payouts/index.tsx - About 2 hrs to fix

    File index.tsx has 263 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 { DeriveStakerReward } from '@polkadot/api-derive/types';
    import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
    Severity: Minor
    Found in packages/page-staking/src/Payouts/index.tsx - About 2 hrs to fix

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

      // Copyright 2017-2024 @polkadot/app-poll authors & contributors
      // SPDX-License-Identifier: Apache-2.0
      
      import type { Approvals, Balance, BlockNumber } from '@polkadot/types/interfaces';
      import type { ITuple } from '@polkadot/types/types';
      Severity: Minor
      Found in packages/page-poll/src/index.tsx - About 2 hrs to fix

        Function getChartResult has 57 lines of code (exceeds 25 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: Major
        Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 2 hrs to fix

          Function Deploy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex }: Props): React.ReactElement<Props> {
            const { t } = useTranslation();
            const { api } = useApi();
            const [initTx, setInitTx] = useState<SubmittableExtrinsic<'promise'> | null>(null);
            const [accountId, isAccountIdValid, setAccountId] = useFormField<string | null>(null);
          Severity: Minor
          Found in packages/page-contracts/src/Contracts/Deploy.tsx - About 2 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 extractInfo has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          function extractInfo (info: PalletReferendaReferendumInfoConvictionVotingTally | PalletReferendaReferendumInfoRankedCollectiveTally, track?: PalletReferendaTrackInfo): { confirmEnd: BN | null, enactAt: { at: boolean, blocks: BN, end: BN | null } | null, nextAlarm: null | BN, submittedIn: null | BN } {
            let confirmEnd: BN | null = null;
            let enactAt: { at: boolean, blocks: BN, end: BN | null } | null = null;
            let nextAlarm: BN | null = null;
            let submittedIn: BN | null = null;
          Severity: Minor
          Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 2 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 curveDelay has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          export function curveDelay (curve: PalletReferendaCurve, input: BN, div: BN): BN {
            try {
              // if divisor is zero, we return the max
              if (div.isZero()) {
                return BN_BILLION;
          Severity: Minor
          Found in packages/page-referenda/src/util.ts - About 2 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 findComponent has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function findComponent (registry: Registry, def: TypeDef, overrides: ComponentMap = {}): React.ComponentType<Props> {
            // Explicit/special handling for Account20/32 types where they don't match
            // the actual chain we are connected to
            if (['AccountId20', 'AccountId32'].includes(def.type)) {
              const defType = `AccountId${registry.createType('AccountId').length}`;
          Severity: Minor
          Found in packages/react-params/src/Param/findComponent.ts - About 2 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 valueToText has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function valueToText (type: string, value: Codec | undefined | null): React.ReactNode {
            if (isNull(value) || isUndefined(value)) {
              const { cName, key, values } = div({}, '<unknown>');
          
              return (
          Severity: Minor
          Found in packages/react-params/src/valueToText.tsx - About 2 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 InputNumber has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, className = '', defaultValue, isDecimal, isDisabled, isError = false, isFull, isLoading, isSi, isSigned = false, isWarning, isZeroable = true, label, labelExtra, maxLength, maxValue, onChange, onEnter, onEscape, placeholder, siDecimals, siDefault, siSymbol, value: propsValue }: Props): React.ReactElement<Props> {
            const { t } = useTranslation();
            const { api } = useApi();
            const [si] = useState<SiDef | null>(() =>
              isSi
          Severity: Minor
          Found in packages/react-components/src/InputNumber.tsx - About 2 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 getLocks has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getLocks (api: ApiPromise, palletVote: PalletVote, votes: [classId: BN, refIds: BN[], casting: PalletConvictionVotingVoteCasting][], referenda: [BN, PalletReferendaReferendumInfoConvictionVotingTally][]): Lock[] {
            const lockPeriod = api.consts[palletVote].voteLockingPeriod as BN;
            const locks: Lock[] = [];
          
            for (let i = 0, voteCount = votes.length; i < voteCount; i++) {
          Severity: Major
          Found in packages/page-referenda/src/useAccountLocks.ts - About 2 hrs to fix

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

            // Copyright 2017-2024 @polkadot/react-components authors & contributors
            // SPDX-License-Identifier: Apache-2.0
            
            import type { IconName } from '@fortawesome/fontawesome-svg-core';
            import type { QueueStatus, QueueTx, QueueTxStatus } from './types.js';
            Severity: Minor
            Found in packages/react-components/src/Status/index.tsx - About 2 hrs to fix

              Function useScheduledImpl has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function useScheduledImpl (): EntryInfoTyped[] {
                const { api } = useApi();
                const blockTime = useBlockInterval();
                const bestNumber = useBestNumber();
                const leaseRangeMax = useLeaseRangeMax();
              Severity: Major
              Found in packages/page-calendar/src/useScheduled.ts - About 2 hrs to fix

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

                // Copyright 2017-2024 @polkadot/app-settings authors & contributors
                // SPDX-License-Identifier: Apache-2.0
                
                import FileSaver from 'file-saver';
                import React, { useCallback, useEffect, useState } from 'react';
                Severity: Minor
                Found in packages/page-settings/src/I18n/index.tsx - About 2 hrs to fix

                  Function extractEvents has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function extractEvents (result?: SubmittableResult): ActionStatus[] {
                    return mergeStatus(
                      (result?.events || [])
                        // filter events handled globally, or those we are not interested in, these are
                        // handled by the global overview, so don't add them here
                  Severity: Major
                  Found in packages/react-hooks/src/ctx/Queue.tsx - About 2 hrs to fix

                    Function useOwnEraRewardsImpl has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function useOwnEraRewardsImpl (maxEras?: number, ownValidators?: StakerState[], additional?: string[]): State {
                      const { api } = useApi();
                      const mountedRef = useIsMountedRef();
                      const stashIds = useOwnStashIds(additional);
                      const allEras = useCall<EraIndex[]>(api.derive.staking?.erasHistoric);
                    Severity: Major
                    Found in packages/react-hooks/src/useOwnEraRewards.ts - About 2 hrs to fix

                      Function loadOnReady has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, fork: Blockchain | null, injectedPromise: Promise<InjectedExtension[]>, store: KeyringStore | undefined, types: Record<string, Record<string, string>>, urlIsEthereum = false): Promise<ApiState> {
                        statics.registry.register(types);
                      
                        const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise);
                        const chainSS58 = properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber();
                      Severity: Major
                      Found in packages/react-api/src/Api.tsx - About 2 hrs to fix

                        File Queue.tsx has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // Copyright 2017-2024 @polkadot/react-hooks authors & contributors
                        // SPDX-License-Identifier: Apache-2.0
                        
                        import type { SubmittableResult } from '@polkadot/api';
                        import type { SubmittableExtrinsic } from '@polkadot/api/promise/types';
                        Severity: Minor
                        Found in packages/react-hooks/src/ctx/Queue.tsx - About 2 hrs to fix

                          Function useTreasuryImpl has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function useTreasuryImpl (): Result {
                            const { api } = useApi();
                            const [result, setResult] = useState<Result>(() => ({
                              pendingBounties: BN_ZERO,
                              pendingProposals: BN_ZERO,
                          Severity: Major
                          Found in packages/react-hooks/src/useTreasury.ts - About 2 hrs to fix

                            Function Upload has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function Upload ({ onClose }: Props): React.ReactElement {
                              const { t } = useTranslation();
                              const { api } = useApi();
                              const [accountId, setAccountId] = useAccountId();
                              const [step, nextStep, prevStep] = useStepper();
                            Severity: Minor
                            Found in packages/page-contracts/src/Codes/Upload.tsx - About 2 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

                            Severity
                            Category
                            Status
                            Source
                            Language