polkadot-js/apps

View on GitHub

Showing 609 of 2,082 total issues

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 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

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 group has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function group (tracks: TrackDescription[], totalIssuance?: BN, referenda?: Referendum[]): ReferendaGroup[] {
  if (!referenda || !totalIssuance) {
    // return an empty group when we have no referenda
    return [{ key: 'empty' }];
  } else if (!tracks) {
Severity: Minor
Found in packages/page-referenda/src/useReferenda.ts - About 1 hr to fix

    Function keyOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function keyOptions (api: ApiPromise, sectionName: string): DropdownOptions {
      const section = api.query[sectionName];
    
      if (!section || Object.keys(section).length === 0) {
        return [];
    Severity: Minor
    Found in packages/react-components/src/InputStorage/options/key.tsx - About 1 hr to fix

      Function getCachedComponent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstance {
        const { blockHash, id, isConst, key, params = [] } = query as StorageModuleQuery;
      
        if (!cache[id]) {
          let renderHelper;
      Severity: Minor
      Found in packages/page-storage/src/Query.tsx - About 1 hr to fix

        Function ErrorDisplay has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function ErrorDisplay (props: Props): React.ReactElement<Props> {
          const { t } = useTranslation();
          const [{ details, type }, setDetails] = useState<Details>({});
        
          useEffect((): void => {
        Severity: Minor
        Found in packages/react-params/src/Param/DispatchError.tsx - About 1 hr to fix

          Function create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function create (t: TFunction): Routes {
            return [
              accounts(t),
              addresses(t),
              explorer(t),
          Severity: Minor
          Found in packages/apps-routing/src/index.ts - About 1 hr to fix

            Function getPoints has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getPoints (details: Detail[], timeAvg: number): ChartInfo {
              const blocks: ChartContents = {
                labels: [],
                values: [[], []]
              };
            Severity: Minor
            Found in packages/page-explorer/src/Latency/index.tsx - About 1 hr to fix

              Function useTeleportImpl has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function useTeleportImpl (): Teleport {
                const { api, apiUrl, isApiReady } = useApi();
                const paraId = useCall<ParaId>(isApiReady && api.query.parachainInfo?.parachainId);
                const [state, setState] = useState<Teleport>(() => ({ ...DEFAULT_STATE }));
              
              
              Severity: Minor
              Found in packages/react-hooks/src/useTeleport.ts - About 1 hr to fix

                Function extractBaseInfo has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: DeriveStakingElected, waitingDerive: DeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial<SortedTargets> {
                  const [elected, nominators] = extractSingle(api, allAccounts, electedDerive, favorites, lastEraInfo, historyDepth, true);
                  const [waiting] = extractSingle(api, allAccounts, waitingDerive, favorites, lastEraInfo);
                  const activeTotals = elected
                    .filter(({ isActive }) => isActive)
                Severity: Minor
                Found in packages/page-staking-legacy/src/useSortedTargets.ts - About 1 hr to fix

                  Function extractBaseInfo has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: DeriveStakingElected, waitingDerive: DeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial<SortedTargets> {
                    const [elected, nominators] = extractSingle(api, allAccounts, electedDerive, favorites, lastEraInfo, historyDepth, true);
                    const [waiting] = extractSingle(api, allAccounts, waitingDerive, favorites, lastEraInfo);
                    const activeTotals = elected
                      .filter(({ isActive }) => isActive)
                  Severity: Minor
                  Found in packages/page-staking/src/useSortedTargets.ts - About 1 hr to fix

                    Function needsApiCheck has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function needsApiCheck (api: ApiPromise): boolean {
                      if (typeof api.query.staking.erasStakersOverview === 'function') {
                        return false;
                      }
                    
                    
                    Severity: Minor
                    Found in packages/apps-routing/src/stakingLegacy.ts - About 1 hr to fix

                      Function Import has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Import ({ className = '', onClose, onStatusChange }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api, isDevelopment, isEthereum } = useApi();
                        const [isBusy, setIsBusy] = useState(false);
                        const [pair, setPair] = useState<KeyringPair | null>(null);
                      Severity: Minor
                      Found in packages/page-accounts/src/modals/Import.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 Overview has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Overview ({ className = '', onStatusChange }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api, fork, isElectron } = useApi();
                        const { allAccounts, hasAccounts } = useAccounts();
                        const { isIpfs } = useIpfs();
                      Severity: Minor
                      Found in packages/page-accounts/src/Accounts/index.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 Slashes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Slashes ({ buttons, councilId, councilThreshold, slash }: Props): React.ReactElement<Props> | null {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const councilMod = useCollectiveInstance('council');
                        const [{ selected, txAll, txSome }, setSelected] = useState<Selected>((): Selected => {
                      Severity: Minor
                      Found in packages/page-staking-legacy/src/Slashes/Era.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 Slashes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Slashes ({ buttons, councilId, councilThreshold, slash }: Props): React.ReactElement<Props> | null {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const councilMod = useCollectiveInstance('council');
                        const [{ selected, txAll, txSome }, setSelected] = useState<Selected>((): Selected => {
                      Severity: Minor
                      Found in packages/page-staking/src/Slashes/Era.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 Proposal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Proposal ({ approvedIds, id, scheduled }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const { allAccounts } = useAccounts();
                        const { hasSudoKey, sudoKey } = useSudo();
                      Severity: Minor
                      Found in packages/page-parachains/src/Proposals/Proposal.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 Fasttrack has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Fasttrack ({ imageHash, members, threshold }: Props): React.ReactElement<Props> | null {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const [isFasttrackOpen, toggleFasttrack] = useToggle();
                        const [accountId, setAcountId] = useState<string | null>(null);
                      Severity: Minor
                      Found in packages/page-democracy/src/Overview/Fasttrack.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 NetworkDisplay has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function NetworkDisplay ({ apiUrl, className = '', setApiUrl, value: { isChild, isRelay, isUnreachable, name, nameRelay: relay, paraId, providers, ui } }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const isSelected = useMemo(
                          () => providers.some(({ url }) => url === apiUrl),
                          [apiUrl, providers]
                      Severity: Minor
                      Found in packages/apps/src/Endpoints/Network.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