lib/_tls_legacy.js

Summary

Maintainability
F
5 days
Test Coverage

File _tls_legacy.js has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
Severity: Major
Found in lib/_tls_legacy.js - About 1 day to fix

    Function read has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    CryptoStream.prototype._read = function read(size) {
      // XXX: EOF?!
      if (!this.pair.ssl) return this.push(null);
    
      // Wait for session to be resumed
    Severity: Minor
    Found in lib/_tls_legacy.js - About 5 hrs 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 write has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    CryptoStream.prototype._write = function write(data, encoding, cb) {
      assert(util.isNull(this._pending));
    
      // Black-hole data
      if (!this.pair.ssl) return cb(null);
    Severity: Minor
    Found in lib/_tls_legacy.js - About 3 hrs 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 onCryptoStreamFinish has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function onCryptoStreamFinish() {
      this._finished = true;
    
      if (this === this.pair.cleartext) {
        debug('cleartext.onfinish');
    Severity: Minor
    Found in lib/_tls_legacy.js - About 2 hrs 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 read has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    CryptoStream.prototype._read = function read(size) {
      // XXX: EOF?!
      if (!this.pair.ssl) return this.push(null);
    
      // Wait for session to be resumed
    Severity: Major
    Found in lib/_tls_legacy.js - About 2 hrs to fix

      Function SecurePair has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function SecurePair(context, isServer, requestCert, rejectUnauthorized,
                          options) {
        if (!(this instanceof SecurePair)) {
          return new SecurePair(context,
                                isServer,
      Severity: Major
      Found in lib/_tls_legacy.js - About 2 hrs to fix

        Function SecurePair has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function SecurePair(context, isServer, requestCert, rejectUnauthorized,
                            options) {
          if (!(this instanceof SecurePair)) {
            return new SecurePair(context,
                                  isServer,
        Severity: Minor
        Found in lib/_tls_legacy.js - About 2 hrs 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 write has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        CryptoStream.prototype._write = function write(data, encoding, cb) {
          assert(util.isNull(this._pending));
        
          // Black-hole data
          if (!this.pair.ssl) return cb(null);
        Severity: Major
        Found in lib/_tls_legacy.js - About 2 hrs to fix

          Function pipe has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.pipe = function pipe(pair, socket) {
            pair.encrypted.pipe(socket);
            socket.pipe(pair.encrypted);
          
            pair.encrypted.on('close', function() {
          Severity: Minor
          Found in lib/_tls_legacy.js - About 1 hr to fix

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

            SecurePair.prototype.error = function(returnOnly) {
              var err = this.ssl.error;
              this.ssl.error = null;
            
              if (!this._secureEstablished) {
            Severity: Minor
            Found in lib/_tls_legacy.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 SecurePair has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function SecurePair(context, isServer, requestCert, rejectUnauthorized,
                                options) {
            Severity: Minor
            Found in lib/_tls_legacy.js - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                    return 'closed';
              Severity: Major
              Found in lib/_tls_legacy.js - About 30 mins to fix

                Function destroySoon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                CryptoStream.prototype.destroySoon = function(err) {
                  if (this === this.pair.cleartext) {
                    debug('cleartext.destroySoon');
                  } else {
                    debug('encrypted.destroySoon');
                Severity: Minor
                Found in lib/_tls_legacy.js - About 25 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 onnewsession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function onnewsession(key, session) {
                  if (!this.server) return;
                
                  var self = this;
                  var once = false;
                Severity: Minor
                Found in lib/_tls_legacy.js - About 25 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 onclienthello has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function onclienthello(hello) {
                  var self = this,
                      once = false;
                
                  this._resumingSession = true;
                Severity: Minor
                Found in lib/_tls_legacy.js - About 25 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

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

                Object.defineProperty(CryptoStream.prototype, 'readyState', {
                  get: function() {
                    if (this._connecting) {
                      return 'opening';
                    } else if (this.readable && this.writable) {
                Severity: Major
                Found in lib/_tls_legacy.js and 1 other location - About 4 hrs to fix
                lib/net.js on lines 372..386

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

                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

                CleartextStream.prototype._internallyPendingBytes = function() {
                  if (this.pair.ssl) {
                    return this.pair.ssl.clearPending();
                  } else {
                    return 0;
                Severity: Major
                Found in lib/_tls_legacy.js and 1 other location - About 1 hr to fix
                lib/_tls_legacy.js on lines 589..595

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

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

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

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

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

                Refactorings

                Further Reading

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

                EncryptedStream.prototype._internallyPendingBytes = function() {
                  if (this.pair.ssl) {
                    return this.pair.ssl.encPending();
                  } else {
                    return 0;
                Severity: Major
                Found in lib/_tls_legacy.js and 1 other location - About 1 hr to fix
                lib/_tls_legacy.js on lines 546..552

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

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

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

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

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

                Refactorings

                Further Reading

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

                CryptoStream.prototype.getSession = function() {
                  if (this.pair.ssl) {
                    return this.pair.ssl.getSession();
                  }
                
                
                Severity: Major
                Found in lib/_tls_legacy.js and 1 other location - About 1 hr to fix
                lib/_tls_legacy.js on lines 399..405

                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

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

                CryptoStream.prototype.isSessionReused = function() {
                  if (this.pair.ssl) {
                    return this.pair.ssl.isSessionReused();
                  }
                
                
                Severity: Major
                Found in lib/_tls_legacy.js and 1 other location - About 1 hr to fix
                lib/_tls_legacy.js on lines 391..397

                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

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

                CryptoStream.prototype.setTimeout = function(timeout, callback) {
                  if (this.socket) this.socket.setTimeout(timeout, callback);
                };
                Severity: Minor
                Found in lib/_tls_legacy.js and 1 other location - About 35 mins to fix
                lib/_tls_legacy.js on lines 374..376

                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

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

                CryptoStream.prototype.setKeepAlive = function(enable, initialDelay) {
                  if (this.socket) this.socket.setKeepAlive(enable, initialDelay);
                };
                Severity: Minor
                Found in lib/_tls_legacy.js and 1 other location - About 35 mins to fix
                lib/_tls_legacy.js on lines 364..366

                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