polkadot-js/common

View on GitHub

Showing 304 of 304 total issues

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

    it('verifies an sr25519 signature', (): void => {
      expect(signatureVerify(MESSAGE, SIG_SR, ADDR_SR)).toEqual({
        crypto: 'sr25519',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an ed25519 signature', (): void => {
      expect(signatureVerify(MESSAGE, MUL_ED, ADDR_ED)).toEqual({
        crypto: 'ed25519',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an ecdsa signature', (): void => {
      expect(signatureVerify(MESSAGE, MUL_EC, ADDR_EC)).toEqual({
        crypto: 'ecdsa',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an ethereum signature', (): void => {
      expect(signatureVerify(MESSAGE, MUL_ET, ADDR_ET)).toEqual({
        crypto: 'ethereum',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an sr25519 signature (without msg wrapper, with wrapped sig)', (): void => {
      expect(signatureVerify(MESSAGE, SIG_SR_WRAP, ADDR_SR_WRAP)).toEqual({
        crypto: 'sr25519',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an ed25519 signature', (): void => {
      expect(signatureVerify(MESSAGE, SIG_ED, ADDR_ED)).toEqual({
        crypto: 'ed25519',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('fails on an invalid signature', (): void => {
      expect(signatureVerify(MESSAGE, SIG_SR, ADDR_ED)).toEqual({
        crypto: 'none',
        isValid: false,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

    it('verifies an ecdsa signature', (): void => {
      expect(signatureVerify(MESSAGE, SIG_EC, ADDR_EC)).toEqual({
        crypto: 'ecdsa',
        isValid: true,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 82..89
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

  it('returns true when the contents do match (u32 only)', (): void => {
    expect(
      u8aEq(
        new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]),
        new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
Severity: Major
Found in packages/util/src/u8a/eq.spec.ts and 1 other location - About 1 hr to fix
packages/util/src/u8a/eq.spec.ts on lines 71..78

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

  it('has the correct starting order', (): void => {
    expect(availableNetworks.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
  });
Severity: Major
Found in packages/networks/src/index.spec.ts and 1 other location - About 1 hr to fix
packages/networks/src/index.spec.ts on lines 112..114

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

  it('returns false when the contents do not match (u32 only)', (): void => {
    expect(
      u8aEq(
        new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]),
        new Uint8Array([1, 2, 3, 4, 5, 6, 7, 9])
Severity: Major
Found in packages/util/src/u8a/eq.spec.ts and 1 other location - About 1 hr to fix
packages/util/src/u8a/eq.spec.ts on lines 80..87

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

    it('fails on invalid ethereum signature', (): void => {
      expect(signatureVerify(MESSAGE, SIG_EC, ADDR_ET)).toEqual({
        crypto: 'none',
        isValid: false,
        isWrapped: false,
Severity: Major
Found in packages/util-crypto/src/signature/verify.spec.ts and 10 other locations - About 1 hr to fix
packages/util-crypto/src/signature/verify.spec.ts on lines 40..47
packages/util-crypto/src/signature/verify.spec.ts on lines 49..56
packages/util-crypto/src/signature/verify.spec.ts on lines 58..65
packages/util-crypto/src/signature/verify.spec.ts on lines 91..98
packages/util-crypto/src/signature/verify.spec.ts on lines 109..116
packages/util-crypto/src/signature/verify.spec.ts on lines 127..134
packages/util-crypto/src/signature/verify.spec.ts on lines 138..145
packages/util-crypto/src/signature/verify.spec.ts on lines 147..154
packages/util-crypto/src/signature/verify.spec.ts on lines 156..163
packages/util-crypto/src/signature/verify.spec.ts on lines 165..172

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

  it('has the correct starting order', (): void => {
    expect(selectableNetworks.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
  });
Severity: Major
Found in packages/networks/src/index.spec.ts and 1 other location - About 1 hr to fix
packages/networks/src/index.spec.ts on lines 12..14

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

    for (j = 0; j < 16; j++) {
      u = (u + h[j]) | 0;
      h[j] = u & 255;
      u >>>= 8;
    }
Severity: Major
Found in packages/util-crypto/src/nacl/tweetnacl.ts and 1 other location - About 1 hr to fix
packages/util-crypto/src/nacl/tweetnacl.ts on lines 231..235

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

    for (j = 0; j < 16; j++) {
      u = (u + h[j]) | 0;
      h[j] = u & 255;
      u >>>= 8;
    }
Severity: Major
Found in packages/util-crypto/src/nacl/tweetnacl.ts and 1 other location - About 1 hr to fix
packages/util-crypto/src/nacl/tweetnacl.ts on lines 224..228

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 core has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function core (out: Uint8Array, inp: Uint8Array, k: Uint8Array, c: Uint8Array, h: boolean): void {
  const w = new Uint32Array(16), x = new Uint32Array(16), y = new Uint32Array(16), t = new Uint32Array(4);
  let i, j, m;

  for (i = 0; i < 4; i++) {
Severity: Minor
Found in packages/util-crypto/src/nacl/tweetnacl.ts - About 1 hr to fix

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

      it('converts BN values to a prefixed hex representation (bitLength)', (): void => {
        expect(
          bnToU8a(new BN(0x123456), { bitLength: 32, isLe: false })
        ).toEqual(new Uint8Array([0x00, 0x12, 0x34, 0x56]));
      });
    Severity: Major
    Found in packages/util/src/bn/toU8a.spec.ts and 1 other location - About 1 hr to fix
    packages/util/src/bn/toU8a.spec.ts on lines 38..42

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

    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('converts using little endian (as set)', (): void => {
        expect(
          bnToU8a(new BN(0x123456), { bitLength: 32, isLe: true })
        ).toEqual(new Uint8Array([0x56, 0x34, 0x12, 0x00]));
      });
    Severity: Major
    Found in packages/util/src/bn/toU8a.spec.ts and 1 other location - About 1 hr to fix
    packages/util/src/bn/toU8a.spec.ts on lines 32..36

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

    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 objectSpread has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function objectSpread <T extends object> (dest: object, ...sources: (object | undefined | null)[]): T {
      for (let i = 0, count = sources.length; i < count; i++) {
        const src = sources[i];
    
        if (src) {
    Severity: Minor
    Found in packages/util/src/object/spread.ts - 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

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

    export function u8aEq (a: string | Uint8Array, b: string | Uint8Array): boolean {
      const u8aa = u8aToU8a(a);
      const u8ab = u8aToU8a(b);
    
      if (u8aa.length === u8ab.length) {
    Severity: Minor
    Found in packages/util/src/u8a/eq.ts - 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

    Severity
    Category
    Status
    Source
    Language