polkadot-js/extension

View on GitHub

Showing 196 of 196 total issues

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

  isOk<T> (value: ResultType<T>): value is ({ ok: T }) {
    return Object.hasOwnProperty.call(value, 'ok');
  },
Severity: Major
Found in packages/extension-ui/src/util/validators.ts and 1 other location - About 1 hr to fix
packages/extension-ui/src/util/validators.ts on lines 14..16

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

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

      const res = await extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
        id: state.allSignRequests[0].id,
        password,
        savePass: false
      }, {} as chrome.runtime.Port);
packages/extension-base/src/background/handlers/Extension.spec.ts on lines 232..236
packages/extension-base/src/background/handlers/Extension.spec.ts on lines 282..286
packages/extension-base/src/background/handlers/Extension.spec.ts on lines 408..412
packages/extension-base/src/background/handlers/Extension.spec.ts on lines 479..483

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

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

  const _onChange = useCallback(
    ({ target: { value } }: React.ChangeEvent<HTMLTextAreaElement>): void => {
      onChange && onChange(value);
    },
    [onChange]
Severity: Major
Found in packages/extension-ui/src/components/TextAreaWithLabel.tsx and 1 other location - About 1 hr to fix
packages/extension-ui/src/components/InputWithLabel.tsx on lines 48..53

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

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 default styled(Link)<Props>(({ isDanger }) => `
  align-items: center;
  color: var(${isDanger ? '--textColorDanger' : '--textColor'});
  display: flex;
  opacity: 0.85;
Severity: Major
Found in packages/extension-ui/src/components/Link.tsx and 1 other location - About 1 hr to fix
packages/extension-ui/src/components/Button.tsx on lines 48..106

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

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 default styled(Button)<ButtonProps>(({ isDanger }) => `
  background: var(${isDanger ? '--buttonBackgroundDanger' : '--buttonBackground'});
  cursor: pointer;
  display: block;
  width: 100%;
Severity: Major
Found in packages/extension-ui/src/components/Button.tsx and 1 other location - About 1 hr to fix
packages/extension-ui/src/components/Link.tsx on lines 54..74

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

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

Function useGenesisHashOptions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function useGenesisHashOptions (): Option[] {
  const { t } = useTranslation();
  const [metadataChains, setMetadatachains] = useState<Option[]>([]);

  useEffect(() => {
Severity: Minor
Found in packages/extension-ui/src/hooks/useGenesisHashOptions.ts - About 1 hr to fix

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

    function InputFile ({ accept, className = '', clearContent, convertHex, isDisabled, isError = false, label, onChange, placeholder }: InputFileProps): React.ReactElement<InputFileProps> {
      const { t } = useTranslation();
      const dropRef = createRef<DropzoneRef>();
      const [file, setFile] = useState<FileState | undefined>();
    
    
    Severity: Minor
    Found in packages/extension-ui/src/components/InputFileWithLabel.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

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

            <tr>
              <td className='label'>{t('symbol')}</td>
              <td className='data'>{request.tokenSymbol}</td>
            </tr>
    Severity: Major
    Found in packages/extension-ui/src/Popup/Metadata/Request.tsx and 3 other locations - About 1 hr to fix
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 50..53
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 54..57
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 58..61

    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

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

    function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused, isReadOnly, label = '', onBlur, onChange, onEnter, placeholder, type = 'text', value, withoutMargin }: Props): React.ReactElement<Props> {
      const [isCapsLock, setIsCapsLock] = useState(false);
      const { t } = useTranslation();
    
      const _checkKey = useCallback(
    Severity: Minor
    Found in packages/extension-ui/src/components/InputWithLabel.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

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

            <tr>
              <td className='label'>{t('decimals')}</td>
              <td className='data'>{request.tokenDecimals}</td>
            </tr>
    Severity: Major
    Found in packages/extension-ui/src/Popup/Metadata/Request.tsx and 3 other locations - About 1 hr to fix
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 50..53
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 54..57
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 62..65

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

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

            <tr>
              <td className='label'>{t('icon')}</td>
              <td className='data'>{request.icon}</td>
            </tr>
    Severity: Major
    Found in packages/extension-ui/src/Popup/Metadata/Request.tsx and 3 other locations - About 1 hr to fix
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 50..53
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 58..61
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 62..65

    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 4 locations. Consider refactoring.
    Open

            <tr>
              <td className='label'>{t('chain')}</td>
              <td className='data'>{request.chain}</td>
            </tr>
    Severity: Major
    Found in packages/extension-ui/src/Popup/Metadata/Request.tsx and 3 other locations - About 1 hr to fix
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 54..57
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 58..61
    packages/extension-ui/src/Popup/Metadata/Request.tsx on lines 62..65

    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

    Function _onChangeFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        (file: Uint8Array): void => {
          setAccountsInfo(() => []);
    
          let json: KeyringPair$Json | KeyringPairs$Json | undefined;
    
    
    Severity: Minor
    Found in packages/extension-ui/src/Popup/RestoreJson.tsx - About 1 hr to fix

      Function getLanguageOptions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function getLanguageOptions (): Option[] {
        return [
          // default/native
          {
            text: 'English',
      Severity: Minor
      Found in packages/extension-ui/src/util/getLanguageOptions.ts - About 1 hr to fix

        Function injectMetaMaskWeb3 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function injectMetaMaskWeb3 (win: Web3Window): void {
          // decorate the compat interface
          win.injectedWeb3['Web3Source'] = {
            enable: async (): Promise<Injected> => {
              const providerRaw = await detectEthereumProvider({ mustBeMetaMask: true });
        Severity: Minor
        Found in packages/extension-compat-metamask/src/bundle.ts - About 1 hr to fix

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

            const addOps = useRef(AVAIL.map((value): AccOption => ({
              text: t('Address index {{index}}', { replace: { index: value } }),
              value
            })));
          Severity: Major
          Found in packages/extension-ui/src/Popup/ImportLedger.tsx and 1 other location - About 1 hr to fix
          packages/extension-ui/src/Popup/ImportLedger.tsx on lines 52..55

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

          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

                await extension.handle('id', 'pri(derivation.create)', {
                  name: 'child',
                  parentAddress: address,
                  parentPassword: password,
                  password,
          packages/extension-base/src/background/handlers/Extension.spec.ts on lines 137..143

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

          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

                await extension.handle('id', 'pri(derivation.create)', {
                  name: 'child',
                  parentAddress: address,
                  parentPassword: password,
                  password,
          packages/extension-base/src/background/handlers/Extension.spec.ts on lines 148..154

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

          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