polkadot-js/apps

View on GitHub

Showing 600 of 2,046 total issues

Consider simplifying this complex logical expression.
Open

    if (
      (!withElected || isElected) &&
      (!withIdentity || !!thisIdentity?.hasIdentity) &&
      (!withPayout || !isBabe || (!!lastPayout && daysPayout.gte(lastPayout))) &&
      (!withoutComm || (
Severity: Critical
Found in packages/page-staking-legacy/src/Targets/index.tsx - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (
          (!withElected || isElected) &&
          (!withIdentity || !!thisIdentity?.hasIdentity) &&
          (!withPayout || !isBabe || (!!lastPayout && daysPayout.gte(lastPayout))) &&
          (!withoutComm || (
    Severity: Critical
    Found in packages/page-staking/src/Targets/index.tsx - About 3 hrs to fix

      Function createWsEndpoints has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function createWsEndpoints (t: TFunction = defaultT, firstOnly = false, withSort = true): LinkOption[] {
        return [
          ...createCustom(t),
          {
            isDisabled: false,
      Severity: Major
      Found in packages/apps-config/src/endpoints/index.ts - About 3 hrs to fix

        Function desc has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            (): React.ReactNode => {
              const id: string | null = info && (
                isString(info)
                  ? info
                  : formatNumber(info)
        Severity: Major
        Found in packages/page-calendar/src/DayItem.tsx - About 3 hrs to fix

          Sidebar has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Sidebar {
            public sidebar: HTMLElement;
          
            constructor (sidebar: HTMLElement) {
              this.sidebar = sidebar;
          Severity: Minor
          Found in packages/test-support/src/pagesElements/Sidebar.ts - About 3 hrs to fix

            Function extractSingle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function extractSingle (api: ApiPromise, allAccounts: string[], derive: DeriveStakingElected | DeriveStakingWaiting, favorites: string[], { activeEra, eraLength, lastEra, sessionLength }: LastEra, historyDepth?: BN, withReturns?: boolean): [ValidatorInfo[], Record<string, BN>] {
              const nominators: Record<string, BN> = {};
              const emptyExposure = api.createType('SpStakingExposurePage');
              const emptyExposureMeta = api.createType('SpStakingPagedExposureMetadata');
              const earliestEra = historyDepth && lastEra.sub(historyDepth).iadd(BN_ONE);
            Severity: Minor
            Found in packages/page-staking/src/useSortedTargets.ts - About 3 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 getBytesParams has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function getBytesParams (interimResult: PreimageStatus, someOptStatus: Option<PalletPreimageRequestStatus>): BytesParams {
              const result = objectSpread<PreimageStatus>({}, interimResult, {
                status: someOptStatus.unwrapOr(null)
              });
            
            
            Severity: Minor
            Found in packages/react-hooks/src/usePreimage.ts - About 3 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 createBalanceItems has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function createBalanceItems (formatIndex: number, lookup: Record<string, string>, t: TFunction, { address, balanceDisplay, balancesAll, bestNumber, convictionLocks, democracyLocks, isAllLocked, otherBonded, ownBonded, stakingInfo, votingOf, withBalanceToggle, withLabel }: { address: string; balanceDisplay: BalanceActiveType; balancesAll?: DeriveBalancesAll | DeriveBalancesAccountData; bestNumber?: BlockNumber; convictionLocks?: RefLock[]; democracyLocks?: DeriveDemocracyLock[]; isAllLocked: boolean; otherBonded: BN[]; ownBonded: BN; stakingInfo?: DeriveStakingAccount; votingOf?: Voting; withBalanceToggle: boolean, withLabel: boolean }): React.ReactNode {
              const allItems: React.ReactNode[] = [];
              const deriveBalances = balancesAll as DeriveBalancesAll;
            
              !withBalanceToggle && balanceDisplay.total && allItems.push(
            Severity: Minor
            Found in packages/react-components/src/AddressInfo.tsx - About 3 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 SummarySession has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function SummarySession ({ className, withEra = true, withSession = true }: Props): React.ReactElement<Props> {
              const { t } = useTranslation();
              const { api } = useApi();
              const sessionInfo = useCall<DeriveSessionProgress>(api.derive.session?.progress);
              const forcing = useCall<Forcing>(api.query.staking?.forceEra);
            Severity: Minor
            Found in packages/page-explorer/src/SummarySession.tsx - About 3 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 ProxyOverview.tsx has 295 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 { SubmittableExtrinsic } from '@polkadot/api/types';
            Severity: Minor
            Found in packages/page-accounts/src/modals/ProxyOverview.tsx - About 3 hrs to fix

              Function Input has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              function Input ({ autoFocus = false, children, className, defaultValue, icon, inputClassName, isAction = false, isDisabled = false, isDisabledError = false, isEditable = false, isError = false, isFull = false, isHidden = false, isInPlaceEditor = false, isLoading = false, isReadOnly = false, isWarning = false, label, labelExtra, max, maxLength, min, name, onBlur, onChange, onEnter, onEscape, onKeyDown, onKeyUp, onPaste, placeholder, tabIndex, type = 'text', value, withEllipsis, withLabel }: Props): React.ReactElement<Props> {
                const [stateName] = useState(() => `in_${counter++}_at_${Date.now()}`);
                const [initialValue] = useState(() => defaultValue);
              
                useEffect((): void => {
              Severity: Minor
              Found in packages/react-components/src/Input.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 TxButton has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              function TxButton ({ accountId, className = '', extrinsic: propsExtrinsic, icon, isBasic, isBusy, isDisabled, isIcon, isToplevel, isUnsigned, label, onClick, onFailed, onSendRef, onStart, onSuccess, onUpdate, params, tooltip, tx, withSpinner, withoutLink }: Props): React.ReactElement<Props> {
                const { t } = useTranslation();
                const mountedRef = useIsMountedRef();
                const { queueExtrinsic } = useQueue();
                const [isSending, setIsSending] = useState(false);
              Severity: Minor
              Found in packages/react-components/src/TxButton.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

              File Address.tsx has 288 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                File Api.tsx has 287 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // Copyright 2017-2024 @polkadot/react-api authors & contributors
                // SPDX-License-Identifier: Apache-2.0
                
                import type { Blockchain } from '@acala-network/chopsticks-core';
                import type { LinkOption } from '@polkadot/apps-config/endpoints/types';
                Severity: Minor
                Found in packages/react-api/src/Api.tsx - About 2 hrs to fix

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

                  // Copyright 2017-2024 @polkadot/app-referenda authors & contributors
                  // SPDX-License-Identifier: Apache-2.0
                  
                  import type { RawParam } from '@polkadot/react-params/types';
                  import type { BN } from '@polkadot/util';
                  Severity: Minor
                  Found in packages/page-referenda/src/Referenda/Submit/index.tsx - About 2 hrs to fix

                    Function extractSingle has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function extractSingle (api: ApiPromise, allAccounts: string[], derive: DeriveStakingElected | DeriveStakingWaiting, favorites: string[], { activeEra, eraLength, lastEra, sessionLength }: LastEra, historyDepth?: BN, withReturns?: boolean): [ValidatorInfo[], Record<string, BN>] {
                      const nominators: Record<string, BN> = {};
                      const emptyExposure = api.createType('Exposure');
                      const earliestEra = historyDepth && lastEra.sub(historyDepth).iadd(BN_ONE);
                      const list = new Array<ValidatorInfo>(derive.info.length);
                    Severity: Minor
                    Found in packages/page-staking-legacy/src/useSortedTargets.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 Submit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function Submit ({ className = '', isMember, members, palletReferenda, tracks }: Props): React.ReactElement<Props> | null {
                      const { t } = useTranslation();
                      const { api, specName } = useApi();
                      const bestNumber = useBestNumber();
                      const [isOpen, toggleOpen] = useToggle();
                    Severity: Minor
                    Found in packages/page-referenda/src/Referenda/Submit/index.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

                    File useSortedTargets.ts has 280 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 { DeriveSessionInfo, DeriveStakingElected, DeriveStakingWaiting } from '@polkadot/api-derive/types';
                    Severity: Minor
                    Found in packages/page-staking/src/useSortedTargets.ts - About 2 hrs to fix

                      File useSortedTargets.ts has 275 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 { DeriveSessionInfo, DeriveStakingElected, DeriveStakingWaiting } from '@polkadot/api-derive/types';
                      Severity: Minor
                      Found in packages/page-staking-legacy/src/useSortedTargets.ts - About 2 hrs to fix

                        File Sidebar.tsx has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // Copyright 2017-2024 @polkadot/react-components authors & contributors
                        // SPDX-License-Identifier: Apache-2.0
                        
                        import React, { useRef, useState } from 'react';
                        
                        
                        Severity: Minor
                        Found in packages/react-components/src/AccountSidebar/Sidebar.tsx - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language