msimerson/Haraka

View on GitHub
plugins/queue/smtp_forward.js

Summary

Maintainability
D
1 day
Test Coverage

File smtp_forward.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
// Forward to an SMTP server
// Opens the connection to the ongoing SMTP server at queue time
// and passes back any errors seen on the ongoing server to the
// originating server.
Severity: Minor
Found in plugins/queue/smtp_forward.js - About 2 hrs to fix

    Function queue_forward has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.queue_forward = function (next, connection) {
        const plugin = this;
        const txn = connection?.transaction;
    
        const cfg = plugin.get_config(connection);
    Severity: Major
    Found in plugins/queue/smtp_forward.js - About 2 hrs to fix

      Function set_queue has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.set_queue = function (connection, queue_wanted, domain) {
      
          let dom_cfg = this.cfg[domain];
          if (dom_cfg === undefined) dom_cfg = {};
      
      
      Severity: Minor
      Found in plugins/queue/smtp_forward.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 auth has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.auth = function (cfg, connection, smtp_client) {
      
          connection.loginfo(this, `Configuring authentication for SMTP server ${cfg.host}:${cfg.port}`);
          smtp_client.on('capabilities', () => {
              connection.loginfo(this, 'capabilities received');
      Severity: Minor
      Found in plugins/queue/smtp_forward.js - About 1 hr to fix

        Function auth has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.auth = function (cfg, connection, smtp_client) {
        
            connection.loginfo(this, `Configuring authentication for SMTP server ${cfg.host}:${cfg.port}`);
            smtp_client.on('capabilities', () => {
                connection.loginfo(this, 'capabilities received');
        Severity: Minor
        Found in plugins/queue/smtp_forward.js - About 55 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 get_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.get_config = function (conn) {
        
            if (!conn.transaction) return this.cfg.main;
        
            let dom;
        Severity: Minor
        Found in plugins/queue/smtp_forward.js - About 55 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 check_recipient has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.check_recipient = function (next, connection, params) {
            const txn = connection?.transaction;
            if (!txn) return;
        
            const rcpt = params[0];
        Severity: Minor
        Found in plugins/queue/smtp_forward.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

                if (next_hop === dst_host) return true;
        Severity: Major
        Found in plugins/queue/smtp_forward.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return next(DENYSOFT, "Split transaction, retry soon");
          Severity: Major
          Found in plugins/queue/smtp_forward.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return this.cfg[dom];
            Severity: Major
            Found in plugins/queue/smtp_forward.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  if (!this.cfg[dom]) return this.cfg.main;  // no specific route
              Severity: Major
              Found in plugins/queue/smtp_forward.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        if (!next_hop) return true;
                Severity: Major
                Found in plugins/queue/smtp_forward.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return false;
                  Severity: Major
                  Found in plugins/queue/smtp_forward.js - About 30 mins to fix

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

                    exports.get_mx = function (next, hmail, domain) {
                    
                        const qw = hmail.todo.notes.get('queue.wants')
                        if (qw && qw !== 'smtp_forward') return next()
                    
                    
                    Severity: Minor
                    Found in plugins/queue/smtp_forward.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

                    There are no issues that match your filters.

                    Category
                    Status