polkadot-js/common

View on GitHub

Showing 87 of 304 total issues

Function hdValidatePath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function hdValidatePath (path: string): boolean {
  if (!path.startsWith('m/')) {
    return false;
  }

Severity: Minor
Found in packages/util-crypto/src/hd/validatePath.ts - About 35 mins 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 nToU8a has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function nToU8a <ExtToBn extends ToBn | ToBigInt> (value?: ExtToBn | BN | bigint | number | null, { bitLength = -1, isLe = true, isNegative = false }: NumberOptions = {}): Uint8Array {
  const valueBi = nToBigInt(value);

  if (valueBi === _0n) {
    return bitLength === -1
Severity: Minor
Found in packages/util/src/bi/toU8a.ts - About 35 mins 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 hdLedger has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function hdLedger (_mnemonic: string, path: string): Keypair {
  const words = _mnemonic
    .split(' ')
    .map((s) => s.trim())
    .filter((s) => s);
Severity: Minor
Found in packages/util-crypto/src/hd/ledger/index.ts - About 35 mins 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 hdEthereum has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function hdEthereum (seed: Uint8Array, path = ''): Keypair {
  const I = hmacShaAsU8a(MASTER_SECRET, seed, 512);
  let hd = createCoded(I.slice(0, 32), I.slice(32));

  if (!path || path === 'm' || path === 'M' || path === "m'" || path === "M'") {
Severity: Minor
Found in packages/util-crypto/src/hd/ethereum/index.ts - About 35 mins 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 mnemonicToLegacySeed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function mnemonicToLegacySeed (mnemonic: string, password = '', onlyJs?: boolean, byteLength: 32 | 64 = 32): Uint8Array {
  if (!mnemonicValidate(mnemonic)) {
    throw new Error('Invalid bip39 mnemonic specified');
  } else if (![32, 64].includes(byteLength)) {
    throw new Error(`Invalid seed length ${byteLength}, expected 32 or 64`);
Severity: Minor
Found in packages/util-crypto/src/mnemonic/toLegacySeed.ts - About 35 mins 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 bnToU8a has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, { bitLength = -1, isLe = true, isNegative = false } = DEFAULT_OPTS): Uint8Array {
  const valueBn = bnToBn(value);
  const byteLength = bitLength === -1
    ? Math.ceil(valueBn.bitLength() / 8)
    : Math.ceil((bitLength || 0) / 8);
Severity: Minor
Found in packages/util/src/bn/toU8a.ts - About 35 mins 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

Avoid too many return statements within this function.
Open

          return false;
Severity: Major
Found in packages/util/src/is/utf8.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      return true;
    Severity: Major
    Found in packages/util/src/is/utf8.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return false;
      Severity: Major
      Found in packages/util/src/is/utf8.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return false;
        Severity: Major
        Found in packages/util/src/is/utf8.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return false;
          Severity: Major
          Found in packages/util/src/is/utf8.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return false;
            Severity: Major
            Found in packages/util/src/is/utf8.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                        return false;
              Severity: Major
              Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return false;
                Severity: Major
                Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return false;
                  Severity: Major
                  Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return false;
                    Severity: Major
                    Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                return false;
                      Severity: Major
                      Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                  return false;
                        Severity: Major
                        Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return false;
                          Severity: Major
                          Found in packages/util/src/is/utf8.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                      return false;
                            Severity: Major
                            Found in packages/util/src/is/utf8.ts - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language