polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Function filterEvents has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function filterEvents (allAccounts: string[], t: (key: string, options?: { replace: Record<string, unknown> }) => string, optionsAll?: KeyringOptions, events?: EventRecord[]): ActionStatus[] | null {
  const eventHash = xxhashAsHex(stringToU8a(JSON.stringify(events)));

  if (!optionsAll || !events || eventHash === prevEventHash) {
    return null;
Severity: Minor
Found in packages/apps/src/Content/Status.tsx - About 1 hr to fix

    Function extractState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function extractState (api: ApiPromise, stashId: string, slashes: Option<SlashingSpans>[], nominees: string[], { activeEra }: DeriveSessionIndexes, submittedIn: EraIndex, exposures: Exposure[]): Inactives {
      const max = api.consts.staking?.maxNominatorRewardedPerValidator as u32;
    
      // chilled
      // NOTE With the introduction of the SlashReported event,
    Severity: Minor
    Found in packages/page-staking-legacy/src/Actions/useInactives.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 BannerExtension has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function BannerExtension (): React.ReactElement | null {
      const { t } = useTranslation();
      const { hasInjectedAccounts } = useApi();
      const upgradableCount = useExtensionCounter();
      const phishing = useRef<string>(t('Since some extensions, such as the polkadot-js extension, protects you against all community reported phishing sites, there are valid reasons to use them for additional protection, even if you are not storing accounts in it.'));
    Severity: Minor
    Found in packages/page-accounts/src/Accounts/BannerExtension.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 extractNominators has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function extractNominators (nominations: [StorageKey, Option<Nominations>][]): NominatedByMap {
      const mapped: NominatedByMap = {};
    
      for (let i = 0, nomCount = nominations.length; i < nomCount; i++) {
        const [key, optNoms] = nominations[i];
    Severity: Minor
    Found in packages/page-staking-legacy/src/useNominations.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 useWeightImpl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function useWeightImpl (): UseWeight {
      const { api } = useApi();
      const blockTime = useBlockInterval();
      const isWeightV2 = !!api.registry.createType<WeightV2>('Weight').proofSize;
      const [megaGas, _setMegaGas] = useState<BN>(
    Severity: Minor
    Found in packages/page-contracts/src/useWeight.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 Sudo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Sudo ({ className, isMine, sudoKey }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const { api, apiDefaultTxSudo } = useApi();
      const [withWeight, toggleWithWeight] = useToggle();
      const [method, setMethod] = useState<SubmittableExtrinsic<'promise'> | null>(null);
    Severity: Minor
    Found in packages/page-sudo/src/Sudo.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 CurrentList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function CurrentList ({ className, favorites, hasQueries, isIntentions, isOwn, minCommission, nominatedBy, ownStashIds, paraValidators = DEFAULT_PARAS, recentlyOnline, stakingOverview, targets, toggleFavorite }: Props): React.ReactElement<Props> | null {
      const { t } = useTranslation();
      const { api } = useApi();
      const { byAuthor, eraPoints } = useBlockAuthors();
      const [nameFilter, setNameFilter] = useState<string>('');
    Severity: Minor
    Found in packages/page-staking-legacy/src/Validators/CurrentList.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 Deposits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Deposits ({ canDeposit, canRefund, className = '', decision, id, noMedia, palletReferenda, submit, track }: Props): React.ReactElement<Props> {
      return (
        <StyledTd className={`${className} address ${noMedia ? '' : 'media--1000-noPad'}`}>
          {submit && (
            <AddressMini
    Severity: Minor
    Found in packages/page-referenda/src/Referenda/Deposits/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 BaseBytes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled, isError, label, labelExtra, length = -1, onChange, onEnter, onEscape, size = 'full', validate = defaultValidate, withCopy, withLabel, withLength }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const [defaultValue] = useState(
        (): string | undefined => {
          if (value) {
    Severity: Minor
    Found in packages/react-params/src/Param/BaseBytes.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 expandTuple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function expandTuple (info: Referendum['info']): Expanded {
      const data = info.isApproved
        ? info.asApproved
        : info.isRejected
          ? info.asRejected
    Severity: Minor
    Found in packages/page-referenda/src/Referenda/RefTuple.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 extractNominators has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function extractNominators (nominations: [StorageKey, Option<Nominations>][]): NominatedByMap {
      const mapped: NominatedByMap = {};
    
      for (let i = 0, nomCount = nominations.length; i < nomCount; i++) {
        const [key, optNoms] = nominations[i];
    Severity: Minor
    Found in packages/page-staking/src/useNominations.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 Param has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Param ({ className = '', defaultValue, isDisabled, isError, isOptional, name, onChange, onEnter, onEscape, overrides, registry, type }: Props): React.ReactElement<Props> | null {
      const Component = useMemo(
        () => findComponent(registry, type, overrides),
        [registry, type, overrides]
      );
    Severity: Minor
    Found in packages/react-params/src/Param/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 CurrentList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function CurrentList ({ className, favorites, hasQueries, isIntentions, isOwn, minCommission, nominatedBy, ownStashIds, paraValidators = DEFAULT_PARAS, recentlyOnline, stakingOverview, targets, toggleFavorite }: Props): React.ReactElement<Props> | null {
      const { t } = useTranslation();
      const { api } = useApi();
      const { byAuthor, eraPoints } = useBlockAuthors();
      const [nameFilter, setNameFilter] = useState<string>('');
    Severity: Minor
    Found in packages/page-staking/src/Validators/CurrentList.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 extractState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function extractState (api: ApiPromise, stashId: string, slashes: Option<SlashingSpans>[], nominees: string[], { activeEra }: DeriveSessionIndexes, submittedIn: EraIndex, exposures: Exposure[]): Inactives {
      const max = api.consts.staking?.maxNominatorRewardedPerValidator as u32;
    
      // chilled
      // NOTE With the introduction of the SlashReported event,
    Severity: Minor
    Found in packages/page-staking/src/Actions/useInactives.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 checkVisible has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function checkVisible ({ api, isApiConnected, isApiReady, isDevelopment: isApiDevelopment }: ApiProps, allowTeleport: boolean, hasAccounts: boolean, hasSudo: boolean, { isDevelopment, isHidden, needsAccounts, needsApi, needsApiCheck, needsApiInstances, needsSudo, needsTeleport }: Route['display']): boolean {
      if (isHidden) {
        return false;
      } else if (needsAccounts && !hasAccounts) {
        return false;
    Severity: Minor
    Found in packages/apps/src/Menu/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 Referendum has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Referendum ({ className = '', value: { allAye, allNay, image, imageHash, index, isPassing, status, voteCountAye, voteCountNay, votedAye, votedNay, votedTotal } }: Props): React.ReactElement<Props> | null {
      const { t } = useTranslation();
      const { api } = useApi();
      const { allAccounts } = useAccounts();
      const bestNumber = useBestNumber();
    Severity: Minor
    Found in packages/page-democracy/src/Overview/Referendum.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 Summary has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Summary ({ approvalCount, proposalCount }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const { api } = useApi();
      const bestNumber = useBestNumber();
      const totalProposals = useCall<BN>(api.query.treasury.proposalCount);
    Severity: Minor
    Found in packages/page-treasury/src/Overview/Summary.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 PreimageCall has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function PreimageCall ({ className = '', value }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
    
      return (
        <>
    Severity: Minor
    Found in packages/page-preimages/src/Preimages/Call.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 Toggle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function Toggle ({ className = '', isDisabled, isRadio, label, onChange, preventDefault, value }: Props): React.ReactElement<Props> {
      const _onClick = useCallback(
        (event: React.MouseEvent<HTMLDivElement, MouseEvent>): void => {
          if (!isDisabled) {
            if (preventDefault) {
    Severity: Minor
    Found in packages/react-components/src/Toggle.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 _onInputImportFile has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const _onInputImportFile = useCallback<FunInputFile>((e) => {
        try {
          _onImportResult(t('Importing'));
          const fileReader = new FileReader();
          const files = e.target.files;
    Severity: Minor
    Found in packages/page-files/src/CrustFiles.tsx - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language