lib/_tls_wrap.js

Summary

Maintainability
F
5 days
Test Coverage

File _tls_wrap.js has 650 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright Joyent, Inc. and other Node contributors.
//
// // Emit `beforeExit` if the loop became alive either after emitting
// event, or after running some callbacks.
//
Severity: Major
Found in lib/_tls_wrap.js - About 1 day to fix

    Function connect has 112 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.connect = function(/* [port, host], options, cb */) {
      var args = normalizeConnectArgs(arguments);
      var options = args[0];
      var cb = args[1];
    
    
    Severity: Major
    Found in lib/_tls_wrap.js - About 4 hrs to fix

      Function _init has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      TLSSocket.prototype._init = function(socket) {
        assert(this._handle);
      
        // lib/net.js expect this value to be non-zero if write hasn't been flushed
        // immediately
      Severity: Minor
      Found in lib/_tls_wrap.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 connect has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.connect = function(/* [port, host], options, cb */) {
        var args = normalizeConnectArgs(arguments);
        var options = args[0];
        var cb = args[1];
      
      
      Severity: Minor
      Found in lib/_tls_wrap.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 Server has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Server(/* [options], listener */) {
        var options, listener;
        if (util.isObject(arguments[0])) {
          options = arguments[0];
          listener = arguments[1];
      Severity: Major
      Found in lib/_tls_wrap.js - About 3 hrs to fix

        Function setOptions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        Server.prototype.setOptions = function(options) {
          if (util.isBoolean(options.requestCert)) {
            this.requestCert = options.requestCert;
          } else {
            this.requestCert = false;
        Severity: Minor
        Found in lib/_tls_wrap.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 _init has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        TLSSocket.prototype._init = function(socket) {
          assert(this._handle);
        
          // lib/net.js expect this value to be non-zero if write hasn't been flushed
          // immediately
        Severity: Major
        Found in lib/_tls_wrap.js - About 2 hrs to fix

          Function onHandle has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function onHandle() {
              if (!legacy)
                socket._releaseControl();
          
              if (options.session)
          Severity: Minor
          Found in lib/_tls_wrap.js - About 1 hr to fix

            Function setOptions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Server.prototype.setOptions = function(options) {
              if (util.isBoolean(options.requestCert)) {
                this.requestCert = options.requestCert;
              } else {
                this.requestCert = false;
            Severity: Minor
            Found in lib/_tls_wrap.js - About 1 hr to fix

              Function TLSSocket has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function TLSSocket(socket, options) {
                // Disallow wrapping TLSSocket in TLSSocket
                assert(!(socket instanceof TLSSocket));
              
                net.Socket.call(this, {
              Severity: Minor
              Found in lib/_tls_wrap.js - About 1 hr to fix

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

                function requestOCSP(self, hello, ctx, cb) {
                  if (!hello.OCSPRequest || !self.server)
                    return cb(null);
                
                  if (!ctx)
                Severity: Minor
                Found in lib/_tls_wrap.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 renegotiate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                TLSSocket.prototype.renegotiate = function(options, callback) {
                  var requestCert = this._requestCert,
                      rejectUnauthorized = this._rejectUnauthorized;
                
                  if (typeof options.requestCert !== 'undefined')
                Severity: Minor
                Found in lib/_tls_wrap.js - About 1 hr to fix

                  Function renegotiate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  TLSSocket.prototype.renegotiate = function(options, callback) {
                    var requestCert = this._requestCert,
                        rejectUnauthorized = this._rejectUnauthorized;
                  
                    if (typeof options.requestCert !== 'undefined')
                  Severity: Minor
                  Found in lib/_tls_wrap.js - About 45 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 Server has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Server(/* [options], listener */) {
                    var options, listener;
                    if (util.isObject(arguments[0])) {
                      options = arguments[0];
                      listener = arguments[1];
                  Severity: Minor
                  Found in lib/_tls_wrap.js - About 45 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 loadSession has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function loadSession(self, hello, cb) {
                    var once = false;
                    function onSession(err, session) {
                      if (once)
                        return cb(new Error('TLS session callback was called 2 times'));
                  Severity: Minor
                  Found in lib/_tls_wrap.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 onnewsession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function onnewsession(key, session) {
                    if (!this.server)
                      return;
                  
                    var self = this;
                  Severity: Minor
                  Found in lib/_tls_wrap.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

                    if (util.isBoolean(options.requestCert)) {
                      this.requestCert = options.requestCert;
                    } else {
                      this.requestCert = false;
                    }
                  Severity: Minor
                  Found in lib/_tls_wrap.js and 1 other location - About 40 mins to fix
                  lib/_tls_wrap.js on lines 714..718

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

                    if (util.isBoolean(options.rejectUnauthorized)) {
                      this.rejectUnauthorized = options.rejectUnauthorized;
                    } else {
                      this.rejectUnauthorized = false;
                    }
                  Severity: Minor
                  Found in lib/_tls_wrap.js and 1 other location - About 40 mins to fix
                  lib/_tls_wrap.js on lines 708..712

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

                  TLSSocket.prototype.getSession = function() {
                    if (this.ssl) {
                      return this.ssl.getSession();
                    }
                  
                  
                  Severity: Minor
                  Found in lib/_tls_wrap.js and 1 other location - About 40 mins to fix
                  lib/_tls_wrap.js on lines 501..507

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

                  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

                  TLSSocket.prototype.isSessionReused = function() {
                    if (this.ssl) {
                      return this.ssl.isSessionReused();
                    }
                  
                  
                  Severity: Minor
                  Found in lib/_tls_wrap.js and 1 other location - About 40 mins to fix
                  lib/_tls_wrap.js on lines 493..499

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

                  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