polkadot-js/apps

View on GitHub

Showing 600 of 2,052 total issues

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

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

function fromDef ({ displayName, info, lookupName, sub, type }: TypeDef): string {
  if (displayName && SPECIAL_TYPES.includes(displayName)) {
    return displayName;
  } else if (type.endsWith('RuntimeSessionKeys')) {
    return 'RuntimeSessionKeys';
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 approxChanges has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function approxChanges (threshold: VoteThreshold, sqrtElectorate: BN, state: ApproxState): Approx {
  const isPassing = calcPassing(threshold, sqrtElectorate, state);

  // simple case, we have an aye > nay to determine passing
  if (threshold.isSimpleMajority) {
Severity: Minor
Found in packages/page-democracy/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 Parachain has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function Parachain ({ bestNumber, className = '', id, lastBacked, lastInclusion, lastTimeout, leasePeriod, nextAction, sessionValidators, validators }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();
  const paraInfo = useParaInfo(id);
  const [nonBacked, setNonBacked] = useState<AccountId[]>([]);

Severity: Minor
Found in packages/page-parachains/src/Overview/Parachain.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 MultisigApprove.tsx has 253 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 { SubmittableExtrinsic } from '@polkadot/api/types';
import type { AccountId, Call, H256, Multisig } from '@polkadot/types/interfaces';
Severity: Minor
Found in packages/page-accounts/src/modals/MultisigApprove.tsx - About 2 hrs to fix

    Function useLatencyImpl has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function useLatencyImpl (): Result {
      const { api } = useApi();
      const [details, setDetails] = useState<Detail[]>([]);
      const signedBlock = useCall<SignedBlockExtended>(api.derive.chain.subscribeNewBlocks);
      const hasHistoric = useRef(false);
    Severity: Major
    Found in packages/page-explorer/src/Latency/useLatency.ts - About 2 hrs to fix

      Function Cid has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Cid (props: Props): React.ReactElement<Props> {
        const { className = '', defaultValue, isDisabled, isError, label, onChange, withLabel } = props;
        const [isValid, setIsValid] = useState(false);
        const [ipfsCid] = useState<string | null>(() =>
          isDisabled && defaultValue && isCodec(defaultValue.value)
      Severity: Minor
      Found in packages/react-params/src/Param/Cid.tsx - About 2 hrs to fix

        Function createLanguages has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function createLanguages (t: TFunction): Option[] {
          return [
            {
              text: t('lng.detect', 'Default browser language (auto-detect)', { ns: 'apps-config' }),
              value: 'default'
        Severity: Minor
        Found in packages/apps-config/src/settings/languages.ts - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

            if (
              // cannot be negative
              (!isSigned && bn.lt(BN_ZERO)) ||
              // cannot be > than allowed max
              bn.gt(getGlobalMaxValue(bitLength)) ||
          Severity: Critical
          Found in packages/react-components/src/InputNumber.tsx - About 2 hrs to fix

            Function calcSlashEras has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function calcSlashEras (slashes: [BN, UnappliedSlash[]][], ownStashes: StakerState[]): SlashEra[] {
              const slashEras: SlashEra[] = [];
            
              slashes
                .reduce((rows: Slash[], [era, slashes]): Slash[] => {
            Severity: Minor
            Found in packages/page-staking-legacy/src/Slashes/index.tsx - About 1 hr to fix

              Function calcSlashEras has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function calcSlashEras (slashes: [BN, UnappliedSlash[]][], ownStashes: StakerState[]): SlashEra[] {
                const slashEras: SlashEra[] = [];
              
                slashes
                  .reduce((rows: Slash[], [era, slashes]): Slash[] => {
              Severity: Minor
              Found in packages/page-staking/src/Slashes/index.tsx - About 1 hr to fix

                Function AddressInfo has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function AddressInfo (props: Props): React.ReactElement<Props> {
                  const { t } = useTranslation();
                  const bestNumber = useBestNumber();
                  const { children, className = '', extraInfo, withBalanceToggle, withHexSessionId } = props;
                
                
                Severity: Minor
                Found in packages/react-components/src/AddressInfo.tsx - About 1 hr to fix

                  Function IdentityMain has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function IdentityMain ({ address, className = '', onClose }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const { apiIdentity, enableIdentity, specName } = useApi();
                    const identityOpt = useCall<Option<ITuple<[PalletIdentityRegistration, Option<Bytes>]>>>(apiIdentity.query.identity.identityOf, [address]);
                    const [{ okAll, okDiscord, okDisplay, okEmail, okGithub, okLegal, okMatrix, okRiot, okTwitter, okWeb }, setOkInfo] = useState<ValueState>({ okAll: false });
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/IdentityMain.tsx - About 1 hr 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 sort has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function sort (a: Validator, b: Validator): number {
                    return a.isFavorite === b.isFavorite
                      ? a.isOwned === b.isOwned
                        ? a.isElected === b.isElected
                          ? 0
                  Severity: Minor
                  Found in packages/page-staking2/src/useTaggedValidators.ts - About 1 hr 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 Derive has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Derive ({ className = '', from, onClose }: Props): React.ReactElement {
                    const { t } = useTranslation();
                    const { api, isDevelopment } = useApi();
                    const { queueAction } = useQueue();
                    const [source] = useState(() => keyring.getPair(from));
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/Derive.tsx - About 1 hr 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 IdentitySubModal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function IdentitySubModal ({ address, className, onClose }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const { apiIdentity, enableIdentity } = useApi();
                    const { allAccounts } = useAccounts();
                    const queryIds = useSubidentities(address);
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/IdentitySub.tsx - About 1 hr 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 sortCampaigns has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function sortCampaigns (a: Campaign, b: Campaign): number {
                    return a.isWinner !== b.isWinner
                      ? a.isWinner
                        ? -1
                        : 1
                  Severity: Minor
                  Found in packages/page-parachains/src/useFunds.ts - About 1 hr 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 Verify has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Verify ({ className = '' }: Props): React.ReactElement {
                    const { t } = useTranslation();
                    const { isEthereum } = useApi();
                    const [{ cryptoType, isValid }, setValidity] = useState<{ cryptoType: CryptoTypes; isValid: boolean }>({ cryptoType: 'unknown', isValid: false });
                    const [{ data, isHexData }, setData] = useState<{ data: string; isHexData: boolean }>({ data: '', isHexData: false });
                  Severity: Minor
                  Found in packages/page-signing/src/Verify.tsx - About 1 hr 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 getAllCalls has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getAllCalls (api: ApiPromise): [Record<string, Record<string, DefinitionCallNamed>>, DefinitionCallNamed | null] {
                    const result: Record<string, Record<string, DefinitionCallNamed>> = {};
                    let defValue: DefinitionCallNamed | null = null;
                    const sections = getEntries(api.call);
                  
                  
                  Severity: Minor
                  Found in packages/react-components/src/InputCalls/useRuntime.ts - About 1 hr 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 Identity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Identity ({ address, identity }: Props): React.ReactElement<Props> | null {
                    const { t } = useTranslation();
                    const { apiIdentity } = useApi();
                    const { isRegistrar, registrars } = useRegistrars();
                    const [isJudgementOpen, toggleIsJudgementOpen] = useToggle();
                  Severity: Minor
                  Found in packages/react-components/src/AccountSidebar/Identity.tsx - About 1 hr 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