polkadot-js/extension

View on GitHub
packages/extension-ui/src/components/Address.spec.tsx

Summary

Maintainability
D
2 days
Test Coverage

Function genericTestSuite has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const genericTestSuite = (account: AccountTestJson, withAccountsInContext = true) => {
  let wrapper: ReactWrapper;
  const { address, expectedIconTheme, name = '', type = DEFAULT_TYPE } = account;

  describe(`Account ${withAccountsInContext ? 'in context from address' : 'from props'} (${name}) - ${type}`, () => {
Severity: Major
Found in packages/extension-ui/src/components/Address.spec.tsx - About 2 hrs to fix

    File Address.spec.tsx has 252 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/components/Address.spec.tsx - About 2 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 2 locations. Consider refactoring.
      Open

          it('can copy its address', () => {
            // the first CopyToClipboard is from the identicon, the second from the copy button
            expect(wrapper.find('CopyToClipboard').at(0).prop('text')).toEqual(address);
            expect(wrapper.find('CopyToClipboard').at(1).prop('text')).toEqual(address);
          });
      Severity: Major
      Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 2 hrs to fix
      packages/extension-ui/src/components/Address.spec.tsx on lines 257..261

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

      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('Copy buttons contain the encoded address', () => {
            // the first CopyToClipboard is from the identicon, the second from the copy button
            expect(wrapper.find('CopyToClipboard').at(0).prop('text')).toEqual(expectedEncodedAddress);
            expect(wrapper.find('CopyToClipboard').at(1).prop('text')).toEqual(expectedEncodedAddress);
          });
      Severity: Major
      Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 2 hrs to fix
      packages/extension-ui/src/components/Address.spec.tsx on lines 177..181

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

      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

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

          it(`shows a ${expectedIconTheme} identicon`, () => {
            expect(wrapper.find('Identicon').first().prop('iconTheme')).toEqual(expectedIconTheme);
          });
      Severity: Major
      Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 1 hr to fix
      packages/extension-ui/src/components/Address.spec.tsx on lines 253..255

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

      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

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

          it(`shows a ${expectedIconTheme} identicon`, () => {
            expect(wrapper.find('Identicon').first().prop('iconTheme')).toEqual(expectedIconTheme);
          });
      Severity: Major
      Found in packages/extension-ui/src/components/Address.spec.tsx and 1 other location - About 1 hr to fix
      packages/extension-ui/src/components/Address.spec.tsx on lines 173..175

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

      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

          it('shows the account correctly reencoded', () => {
            expect(wrapper.find('[data-field="address"]').text()).toEqual(westEndAccount.expectedEncodedAddress);
          });
      Severity: Major
      Found in packages/extension-ui/src/components/Address.spec.tsx and 4 other locations - About 35 mins to fix
      packages/extension-ui/src/Popup/CreateAccount/CreateAccount.spec.tsx on lines 72..74
      packages/extension-ui/src/Popup/ImportQr.spec.tsx on lines 95..97
      packages/extension-ui/src/Popup/ImportQr.spec.tsx on lines 99..101
      packages/extension-ui/src/Popup/ImportQr.spec.tsx on lines 103..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 47.

      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

      There are no issues that match your filters.

      Category
      Status