polkadot-js/extension

View on GitHub

Showing 196 of 196 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('shows Export option if account is not external', async () => {
    wrapper = mountAccountComponent({ isExternal: false, type: 'ed25519' });
    wrapper.find('.settings').first().simulate('click');
    await act(flushAllPromises);

Severity: Major
Found in packages/extension-ui/src/Popup/Accounts/Account.spec.tsx and 1 other location - About 1 day to fix
packages/extension-ui/src/Popup/Accounts/Account.spec.tsx on lines 69..80

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 279.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('shows Derive option if account is of ethereum type', async () => {
    wrapper = mountAccountComponent({ isExternal: false, type: 'ethereum' });
    wrapper.find('.settings').first().simulate('click');
    await act(flushAllPromises);

Severity: Major
Found in packages/extension-ui/src/Popup/Accounts/Account.spec.tsx and 1 other location - About 1 day to fix
packages/extension-ui/src/Popup/Accounts/Account.spec.tsx on lines 45..56

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 279.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <div className='actionArea'>
          <InputWithLabel
            data-export-all-password
            disabled={isBusy}
            isError={pass.length < MIN_LENGTH || !!error}
Severity: Major
Found in packages/extension-ui/src/Popup/ExportAll.tsx and 1 other location - About 1 day to fix
packages/extension-ui/src/Popup/Export.tsx on lines 74..108

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 228.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          <div className='actionArea'>
            <InputWithLabel
              data-export-password
              disabled={isBusy}
              isError={pass.length < MIN_LENGTH || !!error}
Severity: Major
Found in packages/extension-ui/src/Popup/Export.tsx and 1 other location - About 1 day to fix
packages/extension-ui/src/Popup/ExportAll.tsx on lines 71..105

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 228.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export function handleResponse<TMessageType extends MessageTypes> (data: TransportResponseMessage<TMessageType> & { subscription?: string }): void {
  const handler = handlers[data.id];

  if (!handler) {
    console.error(`Unknown response: ${JSON.stringify(data)}`);
Severity: Major
Found in packages/extension-base/src/page/index.ts and 1 other location - About 6 hrs to fix
packages/extension-ui/src/messaging.ts on lines 37..58

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 167.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

port.onMessage.addListener((data: Message['data']): void => {
  const handler = handlers[data.id];

  if (!handler) {
    console.error(`Unknown response: ${JSON.stringify(data)}`);
Severity: Major
Found in packages/extension-ui/src/messaging.ts and 1 other location - About 6 hrs to fix
packages/extension-base/src/page/index.ts on lines 68..89

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 167.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

// Copyright 2019-2024 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { AccountJson, AccountWithChildren } from '@polkadot/extension-base/background/types';
import type { Chain } from '@polkadot/extension-chains/types';
Severity: Minor
Found in packages/extension-ui/src/components/Address.tsx - About 6 hrs to fix

    File Extension.spec.ts has 393 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2019-2024 @polkadot/extension-base authors & contributors
    // SPDX-License-Identifier: Apache-2.0
    
    /// <reference types="@polkadot/dev-test/globals" />
    
    
    Severity: Minor
    Found in packages/extension-base/src/background/handlers/Extension.spec.ts - About 5 hrs to fix

      File types.ts has 337 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Copyright 2019-2024 @polkadot/extension-base authors & contributors
      // SPDX-License-Identifier: Apache-2.0
      
      /* eslint-disable no-use-before-define */
      
      
      Severity: Minor
      Found in packages/extension-base/src/background/types.ts - About 4 hrs to fix

        Function Popup has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function Popup (): React.ReactElement {
          const [accounts, setAccounts] = useState<null | AccountJson[]>(null);
          const [accountCtx, setAccountCtx] = useState<AccountsContext>({ accounts: [], hierarchy: [] });
          const [selectedAccounts, setSelectedAccounts] = useState<AccountJson['address'][]>([]);
          const [authRequests, setAuthRequests] = useState<null | AuthorizeRequest[]>(null);
        Severity: Major
        Found in packages/extension-ui/src/Popup/index.tsx - About 3 hrs to fix

          Function ImportQr has 87 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function ImportQr (): React.ReactElement {
            const { t } = useTranslation();
            const onAction = useContext(ActionContext);
            const [account, setAccount] = useState<QrAccount | null>(null);
            const [address, setAddress] = useState<string | null>(null);
          Severity: Major
          Found in packages/extension-ui/src/Popup/ImportQr.tsx - About 3 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              describe('External account', () => {
                let wrapper: ReactWrapper;
            
                beforeAll(async () => {
                  wrapper = await getWrapper(externalAccount, [], false);
            Severity: Major
            Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 3 hrs to fix
            packages/extension-ui/src/components/Address.spec.tsx on lines 292..302

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 103.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              describe('Hardware wallet account', () => {
                let wrapper: ReactWrapper;
            
                beforeAll(async () => {
                  wrapper = await getWrapper(hardwareAccount, [], false);
            Severity: Major
            Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 3 hrs to fix
            packages/extension-ui/src/components/Address.spec.tsx on lines 280..290

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 103.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                  tabs.handle('1615191860771.5', 'pub(extrinsic.sign)', payload, 'http://localhost:3000', {} as chrome.runtime.Port)
                    .then((result) => {
                      // eslint-disable-next-line jest/no-conditional-expect
                      expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
                    }).catch((err) => console.log(err));
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 226..230
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 276..280
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 342..346
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 473..477

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 97.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                  tabs.handle('1615191860871.5', 'pub(extrinsic.sign)', payload, 'http://localhost:3000', {} as chrome.runtime.Port)
                    .then((result) => {
                      // eslint-disable-next-line jest/no-conditional-expect
                      expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
                    }).catch((err) => console.log(err));
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 276..280
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 342..346
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 402..406
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 473..477

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 97.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                  tabs.handle('1615191860771.5', 'pub(extrinsic.sign)', payload, 'http://localhost:3000', {} as chrome.runtime.Port)
                    .then((result) => {
                      // eslint-disable-next-line jest/no-conditional-expect
                      expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
                    }).catch((err) => console.log(err));
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 226..230
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 276..280
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 402..406
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 473..477

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 97.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                  tabs.handle('1615191860771.5', 'pub(extrinsic.sign)', payload, 'http://localhost:3000', {} as chrome.runtime.Port)
                    .then((result) => {
                      // eslint-disable-next-line jest/no-conditional-expect
                      expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
                    }).catch((err) => console.log(err));
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 226..230
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 276..280
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 342..346
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 402..406

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 97.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                  tabs.handle('1615191860871.5', 'pub(extrinsic.sign)', ethPayload, 'http://localhost:3000', {} as chrome.runtime.Port)
                    .then((result) => {
                      // eslint-disable-next-line jest/no-conditional-expect
                      expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
                    }).catch((err) => console.log(err));
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 226..230
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 342..346
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 402..406
            packages/extension-base/src/background/handlers/Extension.spec.ts on lines 473..477

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 97.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            File Signing.spec.tsx has 292 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // Copyright 2019-2024 @polkadot/extension-ui authors & contributors
            // SPDX-License-Identifier: Apache-2.0
            
            /// <reference types="@polkadot/dev-test/globals" />
            
            
            Severity: Minor
            Found in packages/extension-ui/src/Popup/Signing/Signing.spec.tsx - About 3 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  it('first password changes, then second changes too - button is enabled', async () => {
                    await type(wrapper.find('input[type="password"]').first(), 'abcdef');
                    await type(wrapper.find('input[type="password"]').last(), 'abcdef');
                    expect(wrapper.find('[data-button-action="add new root"] button').prop('disabled')).toBe(false);
                  });
              packages/extension-ui/src/components/AccountNamePasswordCreation.spec.tsx on lines 182..186

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 94.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language