polkadot-js/common

View on GitHub

Showing 304 of 304 total issues

Function secp256k1Recover has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function secp256k1Recover (msgHash: string | Uint8Array, signature: string | Uint8Array, recovery: number, hashType: HashType = 'blake2', onlyJs?: boolean): Uint8Array {
Severity: Minor
Found in packages/util-crypto/src/secp256k1/recover.ts - About 35 mins to fix

    Function vn has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function vn (x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number): number {
    Severity: Minor
    Found in packages/util-crypto/src/nacl/tweetnacl.ts - About 35 mins to fix

      Function crypto_secretbox has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function crypto_secretbox (c: Uint8Array, m: Uint8Array, d: number, n: Uint8Array, k: Uint8Array) {
      Severity: Minor
      Found in packages/util-crypto/src/nacl/tweetnacl.ts - About 35 mins to fix

        Function crypto_secretbox_open has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function crypto_secretbox_open (m: Uint8Array, c: Uint8Array, d: number, n: Uint8Array, k: Uint8Array): number {
        Severity: Minor
        Found in packages/util-crypto/src/nacl/tweetnacl.ts - About 35 mins to fix

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

            it('uses en-gb locale', (): void => {
              expect(
                getSeparator('en-gb')
              ).toEqual({
                decimal: '.',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 21..28
          packages/util/src/format/getSeparator.spec.ts on lines 39..46
          packages/util/src/format/getSeparator.spec.ts on lines 48..55
          packages/util/src/format/getSeparator.spec.ts on lines 57..64
          packages/util/src/format/getSeparator.spec.ts on lines 66..73

          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

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

            it('uses en locale', (): void => {
              expect(
                getSeparator('en')
              ).toEqual({
                decimal: '.',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 30..37
          packages/util/src/format/getSeparator.spec.ts on lines 39..46
          packages/util/src/format/getSeparator.spec.ts on lines 48..55
          packages/util/src/format/getSeparator.spec.ts on lines 57..64
          packages/util/src/format/getSeparator.spec.ts on lines 66..73

          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

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

            it('uses sl-si locale', (): void => {
              expect(
                getSeparator('sl-si')
              ).toEqual({
                decimal: ',',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 21..28
          packages/util/src/format/getSeparator.spec.ts on lines 30..37
          packages/util/src/format/getSeparator.spec.ts on lines 39..46
          packages/util/src/format/getSeparator.spec.ts on lines 57..64
          packages/util/src/format/getSeparator.spec.ts on lines 66..73

          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

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

            it('uses ja-jp locale', (): void => {
              expect(
                getSeparator('ja-jp')
              ).toEqual({
                decimal: '.',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 21..28
          packages/util/src/format/getSeparator.spec.ts on lines 30..37
          packages/util/src/format/getSeparator.spec.ts on lines 39..46
          packages/util/src/format/getSeparator.spec.ts on lines 48..55
          packages/util/src/format/getSeparator.spec.ts on lines 57..64

          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

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

            it('uses sl locale', (): void => {
              expect(
                getSeparator('sl')
              ).toEqual({
                decimal: ',',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 21..28
          packages/util/src/format/getSeparator.spec.ts on lines 30..37
          packages/util/src/format/getSeparator.spec.ts on lines 48..55
          packages/util/src/format/getSeparator.spec.ts on lines 57..64
          packages/util/src/format/getSeparator.spec.ts on lines 66..73

          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

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

            it('uses it-it locale', (): void => {
              expect(
                getSeparator('it-it')
              ).toEqual({
                decimal: ',',
          Severity: Major
          Found in packages/util/src/format/getSeparator.spec.ts and 5 other locations - About 35 mins to fix
          packages/util/src/format/getSeparator.spec.ts on lines 21..28
          packages/util/src/format/getSeparator.spec.ts on lines 30..37
          packages/util/src/format/getSeparator.spec.ts on lines 39..46
          packages/util/src/format/getSeparator.spec.ts on lines 48..55
          packages/util/src/format/getSeparator.spec.ts on lines 66..73

          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

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

          function crypto_stream_salsa20_xor (c: Uint8Array, cpos: number, m: Uint8Array | null, mpos: number, b: number, n: Uint8Array, k: Uint8Array): number {
            const z = new Uint8Array(16), x = new Uint8Array(64);
            let u, i;
            if (!b) return 0;
            for (i = 0; i < 16; i++) z[i] = 0;
          Severity: Minor
          Found in packages/util-crypto/src/nacl/tweetnacl.ts and 1 other location - About 35 mins to fix
          packages/util-crypto/src/nacl/tweetnacl.ts 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 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

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

            it('returns true on all zero values', (): void => {
              expect(
                u8aEmpty(new Uint8Array([0, 0, 0, 0, 0, 0]))
              ).toEqual(true);
            });
          Severity: Minor
          Found in packages/util/src/u8a/empty.spec.ts and 1 other location - About 35 mins to fix
          packages/util/src/u8a/empty.spec.ts on lines 22..26

          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

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

            for (let i = 0, count = keys.length; i < count; i++) {
              objectProperty(that, keys[i], getter, getName, i);
            }
          Severity: Minor
          Found in packages/util/src/object/property.ts and 1 other location - About 35 mins to fix
          packages/util/src/lazy.ts on lines 58..60

          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

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

            for (let i = 0, count = items.length; i < count; i++) {
              lazyMethod(result, items[i], creator, getName, i);
            }
          Severity: Minor
          Found in packages/util/src/lazy.ts and 1 other location - About 35 mins to fix
          packages/util/src/object/property.ts on lines 36..38

          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

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

          function crypto_stream_xor (c: Uint8Array, cpos: number, m: Uint8Array | null, mpos: number, d: number, n: Uint8Array, k: Uint8Array): number {
            const s = new Uint8Array(32);
            core(s, n, k, sigma, true);
            return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, n.subarray(16), s);
          }
          Severity: Minor
          Found in packages/util-crypto/src/nacl/tweetnacl.ts and 1 other location - About 35 mins to fix
          packages/util-crypto/src/nacl/tweetnacl.ts on lines 146..170

          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

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

            it('returns false when value is found', (): void => {
              expect(
                u8aEmpty(new Uint8Array([0, 0, 0, 0, 0, 1]))
              ).toEqual(false);
            });
          Severity: Minor
          Found in packages/util/src/u8a/empty.spec.ts and 1 other location - About 35 mins to fix
          packages/util/src/u8a/empty.spec.ts on lines 16..20

          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

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

          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

          Severity
          Category
          Status
          Source
          Language