polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Avoid deeply nested control flow statements.
Open

          if ((tally.isApproved && vote.isAye) || (tally.isRejected && vote.isNay)) {
            convictionIndex = vote.conviction.index;
            locked = vote.conviction.type;
          }
Severity: Major
Found in packages/page-referenda/src/useAccountLocks.ts - About 45 mins to fix

    Function getTrackInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getTrackInfo (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], trackId?: number): TrackInfoExt | undefined {
      let info: TrackInfoExt | undefined;
    
      if (tracks && trackId !== undefined && trackId !== -1) {
        const originMap = getGovernanceTracks(api, specName, palletReferenda);
    Severity: Minor
    Found in packages/page-referenda/src/util.ts - About 45 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

    Avoid deeply nested control flow statements.
    Open

            } else if (accountVote.isSplit) {
              const { aye, nay } = accountVote.asSplit;
    
              total = aye.add(nay);
            } else if (accountVote.isSplitAbstain) {
    Severity: Major
    Found in packages/page-referenda/src/useAccountLocks.ts - About 45 mins to fix

      Function getChartProps has 6 arguments (exceeds 4 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[] {
      Severity: Minor
      Found in packages/page-referenda/src/Referenda/Referendum.tsx - About 45 mins to fix

        Function getTrackOptions has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function getTrackOptions (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
        Severity: Minor
        Found in packages/page-referenda/src/Referenda/Submit/useTrackOptions.tsx - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (overlapsDisplay(displays, sanitized)) {
                        return false;
                      }
          Severity: Major
          Found in packages/page-staking/src/Targets/index.tsx - About 45 mins to fix

            Function Amount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, registry, type, withLabel }: Props): React.ReactElement<Props> {
              const isSigned = useMemo(
                // Allow signed inputs for i{8, 16, 32, 64, 128, ...} types
                () => /^i\d*$/.test(type.type),
                [type]
            Severity: Minor
            Found in packages/react-params/src/Param/Amount.tsx - About 45 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

            Function mapValidators has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function mapValidators (startWith: Record<string, [GroupIndex, ValidatorInfo[]]>, ids: ParaId[], validators: AccountId[], groups: ParaValidatorIndex[][], indices: ParaValidatorIndex[], scheduled: CoreAssignment[]): Record<string, [GroupIndex, ValidatorInfo[]]> {
            Severity: Minor
            Found in packages/page-parachains/src/Overview/useValidators.ts - About 45 mins to fix

              Function constructTx has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function constructTx (api: ApiPromise, systemChain: string, accountId: string, ethereumSignature: EthereumSignature | string | undefined | null, kind: StatementKind | undefined | null, isOldClaimProcess: boolean): ConstructTx {
              Severity: Minor
              Found in packages/page-claims/src/Claim.tsx - About 45 mins to fix

                Function PreImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function PreImage ({ className = '', imageHash, isImminent = false, onClose }: Props): React.ReactElement<Props> {
                  const { t } = useTranslation();
                  const { api, apiDefaultTxSudo } = useApi();
                  const [accountId, setAccountId] = useState<string | null>(null);
                  const [{ encodedHash, encodedProposal, storageFee }, setHash] = useState<HashState>({ encodedHash: ZERO_HASH, encodedProposal: '', storageFee: null });
                Severity: Minor
                Found in packages/page-democracy/src/Overview/PreImage.tsx - About 45 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

                Function Propose has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function Propose ({ className = '', onClose }: Props): React.ReactElement<Props> {
                  const { t } = useTranslation();
                  const { api } = useApi();
                  const [accountId, setAccountId] = useState<string | null>(null);
                  const [balance, setBalance] = useState<BN | undefined>();
                Severity: Minor
                Found in packages/page-democracy/src/Overview/Propose.tsx - About 45 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

                Function getDiffs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function getDiffs (votes: BN, total: BN, change: BN, inc: BN, totalInc: 0 | 0.1 | 1, direction: 1 | -1): [BN, BN, BN] {
                Severity: Minor
                Found in packages/page-democracy/src/util.ts - About 45 mins to fix

                  Function calcChangeNay has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function calcChangeNay (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState, isPassing: boolean, changeNay: BN, inc: BN): BN {
                  Severity: Minor
                  Found in packages/page-democracy/src/util.ts - About 45 mins to fix

                    Function Connecting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function Connecting ({ className }: Props): React.ReactElement<Props> | null {
                      const { t } = useTranslation();
                      const { apiError, isApiConnected, isApiReady, isWaitingInjected } = useApi();
                    
                      if (apiError) {
                    Severity: Minor
                    Found in packages/apps/src/overlays/Connecting.tsx - About 45 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

                    Function Item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function Item ({ className = '', classNameText, isLink, isToplevel, route: { Modal, href, icon, name, text, useCounter = DUMMY_COUNTER } }: Props): React.ReactElement<Props> {
                      const [isModalVisible, toggleModal] = useToggle();
                      const count = useCounter();
                    
                      return (
                    Severity: Minor
                    Found in packages/apps/src/Menu/Item.tsx - About 45 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

                    Function mergeCurrent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function mergeCurrent (ranges: [number, number][], auctionInfo: AuctionInfo, prev: Winning[] | undefined, optCurrent: Option<WinningData>, blockOffset: BN): Winning[] | undefined {
                      const current = createWinning(auctionInfo, blockOffset, extractWinners(ranges, auctionInfo, optCurrent));
                    
                      if (current.winners.length) {
                        if (!prev?.length) {
                    Severity: Minor
                    Found in packages/page-parachains/src/useWinningData.ts - About 45 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

                    Function extractGroups has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function extractGroups (routing: Routes, groupNames: Record<string, string>, apiProps: ApiProps, allowTeleport: boolean, hasAccounts: boolean, hasSudo: boolean): Group[] {
                    Severity: Minor
                    Found in packages/apps/src/Menu/index.tsx - About 45 mins to fix

                      Function subscribe has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function subscribe <T> (api: ApiPromise, mountedRef: MountedRef, tracker: TrackerRef, calls: QueryableStorageMultiArg<'promise'>[], setValue: (value: T) => void, { transform = transformIdentity }: CallOptions<T> = {}): void {
                      Severity: Minor
                      Found in packages/react-hooks/src/useCallMulti.ts - About 45 mins to fix

                        Function calcChangeAye has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function calcChangeAye (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState, isPassing: boolean, changeAye: BN, inc: BN): BN {
                        Severity: Minor
                        Found in packages/page-democracy/src/util.ts - About 45 mins to fix

                          Function getPosition has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          export function getPosition (triggerPosition: ElementPosition, positionX: HorizontalPosition, positionY: VerticalPosition, windowPosition: ElementPosition, scrollY: number, windowSize: WindowSize): Coords {
                          Severity: Minor
                          Found in packages/react-components/src/Popup/utils.ts - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language