enclose-io/compiler

View on GitHub
lts/lib/internal/crypto/diffiehellman.js

Summary

Maintainability
F
6 days
Test Coverage

Function DiffieHellman has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
  if (!(this instanceof DiffieHellman))
    return new DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding);

  if (typeof sizeOrKey !== 'number' &&
Severity: Minor
Found in lts/lib/internal/crypto/diffiehellman.js - About 1 hr to fix

    Function DiffieHellman has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
      if (!(this instanceof DiffieHellman))
        return new DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding);
    
      if (typeof sizeOrKey !== 'number' &&
    Severity: Minor
    Found in lts/lib/internal/crypto/diffiehellman.js - 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 convertKey has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    ECDH.convertKey = function convertKey(key, curve, inEnc, outEnc, format) {
    Severity: Minor
    Found in lts/lib/internal/crypto/diffiehellman.js - About 35 mins to fix

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

      function diffieHellman(options) {
        if (typeof options !== 'object')
          throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
      
        const { privateKey, publicKey } = options;
      Severity: Minor
      Found in lts/lib/internal/crypto/diffiehellman.js - 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 getFormat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function getFormat(format) {
        if (format) {
          if (format === 'compressed')
            return POINT_CONVERSION_COMPRESSED;
          if (format === 'hybrid')
      Severity: Minor
      Found in lts/lib/internal/crypto/diffiehellman.js - 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

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

      function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
        if (!(this instanceof DiffieHellman))
          return new DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding);
      
        if (typeof sizeOrKey !== 'number' &&
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 1 day to fix
      current/lib/internal/crypto/diffiehellman.js on lines 43..91

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

      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

      function diffieHellman(options) {
        if (typeof options !== 'object')
          throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
      
        const { privateKey, publicKey } = options;
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 1 day to fix
      current/lib/internal/crypto/diffiehellman.js on lines 255..282

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

      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

      ECDH.convertKey = function convertKey(key, curve, inEnc, outEnc, format) {
        if (typeof key !== 'string' && !isArrayBufferView(key)) {
          throw new ERR_INVALID_ARG_TYPE(
            'key',
            ['string', 'Buffer', 'TypedArray', 'DataView'],
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 5 hrs to fix
      current/lib/internal/crypto/diffiehellman.js on lines 216..233

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

      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

      function dhComputeSecret(key, inEnc, outEnc) {
        const encoding = getDefaultEncoding();
        inEnc = inEnc || encoding;
        outEnc = outEnc || encoding;
        const ret = this[kHandle].computeSecret(toBuf(key, inEnc));
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 2 hrs to fix
      current/lib/internal/crypto/diffiehellman.js on lines 121..129

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

      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

      ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
        const f = getFormat(format);
        const key = this[kHandle].getPublicKey(f);
        encoding = encoding || getDefaultEncoding();
        return encode(key, encoding);
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 2 hrs to fix
      current/lib/internal/crypto/diffiehellman.js on lines 209..214

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

      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

      function DiffieHellmanGroup(name) {
        if (!(this instanceof DiffieHellmanGroup))
          return new DiffieHellmanGroup(name);
        this[kHandle] = new _DiffieHellmanGroup(name);
        ObjectDefineProperty(this, 'verifyError', {
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 1 hr to fix
      current/lib/internal/crypto/diffiehellman.js on lines 94..103

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

      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

      DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
        encoding = encoding || getDefaultEncoding();
        this[kHandle].setPrivateKey(toBuf(key, encoding));
        return this;
      };
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 3 other locations - About 1 hr to fix
      current/lib/internal/crypto/diffiehellman.js on lines 176..180
      current/lib/internal/crypto/diffiehellman.js on lines 183..187
      lts/lib/internal/crypto/diffiehellman.js on lines 176..180

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

      DiffieHellman.prototype.setPublicKey = function setPublicKey(key, encoding) {
        encoding = encoding || getDefaultEncoding();
        this[kHandle].setPublicKey(toBuf(key, encoding));
        return this;
      };
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 3 other locations - About 1 hr to fix
      current/lib/internal/crypto/diffiehellman.js on lines 176..180
      current/lib/internal/crypto/diffiehellman.js on lines 183..187
      lts/lib/internal/crypto/diffiehellman.js on lines 183..187

      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

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

      function getFormat(format) {
        if (format) {
          if (format === 'compressed')
            return POINT_CONVERSION_COMPRESSED;
          if (format === 'hybrid')
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 1 hr to fix
      current/lib/internal/crypto/diffiehellman.js on lines 241..251

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

      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

      ECDH.prototype.generateKeys = function generateKeys(encoding, format) {
        this[kHandle].generateKeys();
      
        return this.getPublicKey(encoding, format);
      };
      Severity: Minor
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 45 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 203..207

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

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

      function dhGetPublicKey(encoding) {
        const key = this[kHandle].getPublicKey();
        encoding = encoding || getDefaultEncoding();
        return encode(key, encoding);
      }
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 9 other locations - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 110..114
      current/lib/internal/crypto/diffiehellman.js on lines 136..140
      current/lib/internal/crypto/diffiehellman.js on lines 147..151
      current/lib/internal/crypto/diffiehellman.js on lines 158..162
      current/lib/internal/crypto/diffiehellman.js on lines 169..173
      lts/lib/internal/crypto/diffiehellman.js on lines 110..114
      lts/lib/internal/crypto/diffiehellman.js on lines 136..140
      lts/lib/internal/crypto/diffiehellman.js on lines 147..151
      lts/lib/internal/crypto/diffiehellman.js on lines 169..173

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

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

      function dhGenerateKeys(encoding) {
        const keys = this[kHandle].generateKeys();
        encoding = encoding || getDefaultEncoding();
        return encode(keys, encoding);
      }
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 9 other locations - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 110..114
      current/lib/internal/crypto/diffiehellman.js on lines 136..140
      current/lib/internal/crypto/diffiehellman.js on lines 147..151
      current/lib/internal/crypto/diffiehellman.js on lines 158..162
      current/lib/internal/crypto/diffiehellman.js on lines 169..173
      lts/lib/internal/crypto/diffiehellman.js on lines 136..140
      lts/lib/internal/crypto/diffiehellman.js on lines 147..151
      lts/lib/internal/crypto/diffiehellman.js on lines 158..162
      lts/lib/internal/crypto/diffiehellman.js on lines 169..173

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

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

      function dhGetPrime(encoding) {
        const prime = this[kHandle].getPrime();
        encoding = encoding || getDefaultEncoding();
        return encode(prime, encoding);
      }
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 9 other locations - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 110..114
      current/lib/internal/crypto/diffiehellman.js on lines 136..140
      current/lib/internal/crypto/diffiehellman.js on lines 147..151
      current/lib/internal/crypto/diffiehellman.js on lines 158..162
      current/lib/internal/crypto/diffiehellman.js on lines 169..173
      lts/lib/internal/crypto/diffiehellman.js on lines 110..114
      lts/lib/internal/crypto/diffiehellman.js on lines 147..151
      lts/lib/internal/crypto/diffiehellman.js on lines 158..162
      lts/lib/internal/crypto/diffiehellman.js on lines 169..173

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

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

      function dhGetPrivateKey(encoding) {
        const key = this[kHandle].getPrivateKey();
        encoding = encoding || getDefaultEncoding();
        return encode(key, encoding);
      }
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 9 other locations - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 110..114
      current/lib/internal/crypto/diffiehellman.js on lines 136..140
      current/lib/internal/crypto/diffiehellman.js on lines 147..151
      current/lib/internal/crypto/diffiehellman.js on lines 158..162
      current/lib/internal/crypto/diffiehellman.js on lines 169..173
      lts/lib/internal/crypto/diffiehellman.js on lines 110..114
      lts/lib/internal/crypto/diffiehellman.js on lines 136..140
      lts/lib/internal/crypto/diffiehellman.js on lines 147..151
      lts/lib/internal/crypto/diffiehellman.js on lines 158..162

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

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

      function dhGetGenerator(encoding) {
        const generator = this[kHandle].getGenerator();
        encoding = encoding || getDefaultEncoding();
        return encode(generator, encoding);
      }
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 9 other locations - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 110..114
      current/lib/internal/crypto/diffiehellman.js on lines 136..140
      current/lib/internal/crypto/diffiehellman.js on lines 147..151
      current/lib/internal/crypto/diffiehellman.js on lines 158..162
      current/lib/internal/crypto/diffiehellman.js on lines 169..173
      lts/lib/internal/crypto/diffiehellman.js on lines 110..114
      lts/lib/internal/crypto/diffiehellman.js on lines 136..140
      lts/lib/internal/crypto/diffiehellman.js on lines 158..162
      lts/lib/internal/crypto/diffiehellman.js on lines 169..173

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

      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

      function ECDH(curve) {
        if (!(this instanceof ECDH))
          return new ECDH(curve);
      
        validateString(curve, 'curve');
      Severity: Minor
      Found in lts/lib/internal/crypto/diffiehellman.js and 1 other location - About 40 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 190..196

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

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

      const {
        ERR_CRYPTO_ECDH_INVALID_FORMAT,
        ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY,
        ERR_CRYPTO_INCOMPATIBLE_KEY,
        ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE,
      Severity: Major
      Found in lts/lib/internal/crypto/diffiehellman.js and 6 other locations - About 35 mins to fix
      current/lib/internal/crypto/diffiehellman.js on lines 9..16
      current/lib/internal/crypto/keygen.js on lines 31..38
      current/lib/internal/crypto/keys.js on lines 21..28
      lts/lib/internal/crypto/keygen.js on lines 31..38
      lts/lib/internal/crypto/keys.js on lines 20..27
      lts/lib/internal/modules/esm/loader.js on lines 9..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 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status