msimerson/Haraka

View on GitHub
plugins/tls.js

Summary

Maintainability
B
6 hrs
Test Coverage

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

exports.upgrade_connection = function (next, connection, params) {
    if (!connection.tls.advertised) return next();

    /* Watch for STARTTLS directive from client. */
    if (params[0].toUpperCase() !== 'STARTTLS') return next();
Severity: Minor
Found in plugins/tls.js - About 1 hr to fix

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

    exports.emit_upgrade_msg = function (conn, verified, verifyErr, cert, cipher) {
        let msg = 'secured:';
        if (cipher) {
            msg += ` cipher=${cipher.name} version=${cipher.version}`;
        }
    Severity: Minor
    Found in plugins/tls.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 advertise_starttls has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.advertise_starttls = function (next, connection) {
    
        // if no TLS setup incomplete/invalid, don't advertise
        if (!tls_socket.tls_valid) {
            this.logerror('no valid TLS config');
    Severity: Minor
    Found in plugins/tls.js - About 1 hr to fix

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

      exports.upgrade_connection = function (next, connection, params) {
          if (!connection.tls.advertised) return next();
      
          /* Watch for STARTTLS directive from client. */
          if (params[0].toUpperCase() !== 'STARTTLS') return next();
      Severity: Minor
      Found in plugins/tls.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 emit_upgrade_msg has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      exports.emit_upgrade_msg = function (conn, verified, verifyErr, cert, cipher) {
      Severity: Minor
      Found in plugins/tls.js - About 35 mins to fix

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

        exports.advertise_starttls = function (next, connection) {
        
            // if no TLS setup incomplete/invalid, don't advertise
            if (!tls_socket.tls_valid) {
                this.logerror('no valid TLS config');
        Severity: Minor
        Found in plugins/tls.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

        Avoid too many return statements within this function.
        Open

                return enable_tls();
        Severity: Major
        Found in plugins/tls.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              if (connection.local.port === 587) return enable_tls();
          Severity: Major
          Found in plugins/tls.js - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status