msimerson/Haraka

View on GitHub
outbound/hmail.js

Summary

Maintainability
F
2 wks
Test Coverage

File hmail.js has 1246 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const events       = require('events');
const fs           = require('fs');
const dns          = require('dns');
Severity: Major
Found in outbound/hmail.js - About 3 days to fix

    Function try_deliver_host_on_socket has 467 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        try_deliver_host_on_socket (mx, host, port, socket) {
            const self = this;
            let processing_mail = true;
            let command = mx.using_lmtp ? 'connect_lmtp' : 'connect';
    
    
    Severity: Major
    Found in outbound/hmail.js - About 2 days to fix

      Function try_deliver_host_on_socket has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
      Open

          try_deliver_host_on_socket (mx, host, port, socket) {
              const self = this;
              let processing_mail = true;
              let command = mx.using_lmtp ? 'connect_lmtp' : 'connect';
      
      
      Severity: Minor
      Found in outbound/hmail.js - About 1 day 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 populate_bounce_message_with_headers has 201 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          populate_bounce_message_with_headers (from, to, reason, header, cb) {
              const CRLF = '\r\n';
      
              const originalMessageId = header.get('Message-Id');
      
      
      Severity: Major
      Found in outbound/hmail.js - About 1 day to fix

        HMailItem has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class HMailItem extends events.EventEmitter {
            constructor (filename, filePath, notes) {
                super();
        
                const parts = _qfile.parts(filename);
        Severity: Minor
        Found in outbound/hmail.js - About 3 hrs to fix

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

              found_mx (err, mxs) {
                  if (err) {
                      this.lognotice(`MX Lookup for ${this.todo.domain} failed: ${err}`);
                      if (err.code === dns.NXDOMAIN || err.code === dns.NOTFOUND) {
                          this.todo.rcpt_to.forEach(rcpt => {
          Severity: Minor
          Found in outbound/hmail.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 split_to_new_recipients has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              split_to_new_recipients (recipients, response, cb) {
                  const hmail = this;
                  if (recipients.length === hmail.todo.rcpt_to.length) {
                      // Split to new for no reason - increase refcount and return self
                      hmail.refcount++;
          Severity: Major
          Found in outbound/hmail.js - About 2 hrs to fix

            Function found_mx has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                found_mx (err, mxs) {
                    if (err) {
                        this.lognotice(`MX Lookup for ${this.todo.domain} failed: ${err}`);
                        if (err.code === dns.NXDOMAIN || err.code === dns.NOTFOUND) {
                            this.todo.rcpt_to.forEach(rcpt => {
            Severity: Minor
            Found in outbound/hmail.js - About 1 hr to fix

              Function process_ehlo_data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function process_ehlo_data () {
                          set_ehlo_props();
              
                          if (secured) return auth_and_mail_phase();              // TLS already negotiated
              
              
              Severity: Minor
              Found in outbound/hmail.js - About 1 hr to fix

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

                    try_deliver () {
                
                        // check if there are any MXs left
                        if (this.mxlist.length === 0) {
                            this.todo.rcpt_to.forEach(rcpt => {
                Severity: Minor
                Found in outbound/hmail.js - About 1 hr to fix

                  Function auth_and_mail_phase has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function auth_and_mail_phase () {
                              if (!authenticated && (mx.auth_user && mx.auth_pass)) {
                                  // We have AUTH credentials to send for this domain
                                  if (!(Array.isArray(smtp_properties.auth) && smtp_properties.auth.length)) {
                                      // AUTH not offered
                  Severity: Minor
                  Found in outbound/hmail.js - About 1 hr to fix

                    Function read_todo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        read_todo () {
                            this._stream_bytes_from(this.path, {start: 0, end: 3}, (err, bytes) => {
                                if (err) {
                                    const errMsg = `Error reading queue file ${this.filename}: ${err}`;
                                    this.logerror(errMsg);
                    Severity: Minor
                    Found in outbound/hmail.js - About 1 hr to fix

                      Function get_mx_respond has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          get_mx_respond (retval, mx) {
                              switch (retval) {
                                  case constants.ok: {
                                      let mx_list;
                                      if (Array.isArray(mx)) {
                      Severity: Minor
                      Found in outbound/hmail.js - About 1 hr to fix

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

                            populate_bounce_message (from, to, reason, cb) {
                        
                                let buf = '';
                                const original_header_lines = [];
                                let headers_done = false;
                        Severity: Minor
                        Found in outbound/hmail.js - About 1 hr to fix

                          Function try_deliver_host has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              try_deliver_host (mx) {
                          
                                  if (this.hostlist.length === 0) {
                                      return this.try_deliver(); // try next MX
                                  }
                          Severity: Minor
                          Found in outbound/hmail.js - About 1 hr to fix

                            Function send_command has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    const send_command = socket.send_command = (cmd, data) => {
                                        if (!socket.writable) {
                                            self.logerror("Socket writability went away");
                                            if (processing_mail) {
                                                processing_mail = false;
                            Severity: Minor
                            Found in outbound/hmail.js - About 1 hr to fix

                              Function finish_processing_mail has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      function finish_processing_mail (success) {
                                          if (fp_called) {
                                              return self.logerror(`finish_processing_mail called multiple times! Stack: ${(new Error()).stack}`);
                                          }
                                          fp_called = true;
                              Severity: Minor
                              Found in outbound/hmail.js - About 1 hr to fix

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

                                    try_deliver_host (mx) {
                                
                                        if (this.hostlist.length === 0) {
                                            return this.try_deliver(); // try next MX
                                        }
                                Severity: Minor
                                Found in outbound/hmail.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 populate_bounce_message_with_headers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    populate_bounce_message_with_headers (from, to, reason, header, cb) {
                                        const CRLF = '\r\n';
                                
                                        const originalMessageId = header.get('Message-Id');
                                
                                
                                Severity: Minor
                                Found in outbound/hmail.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_mx_respond has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    get_mx_respond (retval, mx) {
                                        switch (retval) {
                                            case constants.ok: {
                                                let mx_list;
                                                if (Array.isArray(mx)) {
                                Severity: Minor
                                Found in outbound/hmail.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

                                Avoid deeply nested control flow statements.
                                Open

                                                        if (ok_recips.length === 0) {
                                                            return finish_processing_mail(false);
                                                        }
                                Severity: Major
                                Found in outbound/hmail.js - About 45 mins to fix

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

                                      try_deliver () {
                                  
                                          // check if there are any MXs left
                                          if (this.mxlist.length === 0) {
                                              this.todo.rcpt_to.forEach(rcpt => {
                                  Severity: Minor
                                  Found in outbound/hmail.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

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if (command === 'dot_lmtp') last_recip = ok_recips.shift();
                                  Severity: Major
                                  Found in outbound/hmail.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if (command === 'dot_lmtp') {
                                                            response = [];
                                                            if (ok_recips.length === 0) {
                                                                return finish_processing_mail(false);
                                                            }
                                    Severity: Major
                                    Found in outbound/hmail.js - About 45 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                          return client_pool.release_client(socket, port, host, mx.bind, true);
                                      Severity: Major
                                      Found in outbound/hmail.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                                        return send_command(utils.base64(mx.auth_pass));
                                        Severity: Major
                                        Found in outbound/hmail.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return obtls.check_tls_nogo(host,
                                                          () => { // Clear to GO
                                                              self.logdebug(`Trying TLS for domain: ${self.todo.domain}, host: ${host}`);
                                          
                                                              socket.once('secure', () => {
                                          Severity: Major
                                          Found in outbound/hmail.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                return self.temp_fail(`Upstream error: ${code} ${(extc) ? `${extc} ` : ''}${reason}`);
                                            Severity: Major
                                            Found in outbound/hmail.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return send_command('MAIL', `FROM:${self.todo.mail_from.format(!smtp_properties.smtp_utf8)}`);
                                              Severity: Major
                                              Found in outbound/hmail.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                return auth_and_mail_phase();  // no outbound TLS config
                                                Severity: Major
                                                Found in outbound/hmail.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                              if (net_utils.ip_in_list(obtls.cfg.no_tls_hosts, self.todo.domain)) return auth_and_mail_phase();
                                                  Severity: Major
                                                  Found in outbound/hmail.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                    return self.temp_fail(`Upstream error: ${code} ${(extc) ? `${extc} ` : ''}${reason}`);
                                                    Severity: Major
                                                    Found in outbound/hmail.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                                  return finish_processing_mail(false);
                                                      Severity: Major
                                                      Found in outbound/hmail.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                    if (net_utils.ip_in_list(obtls.cfg.no_tls_hosts, host)) return auth_and_mail_phase();
                                                        Severity: Major
                                                        Found in outbound/hmail.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                                  return send_command('MAIL', `FROM:${self.todo.mail_from.format(!smtp_properties.smtp_utf8)}`);
                                                          Severity: Major
                                                          Found in outbound/hmail.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                                        return finish_processing_mail(false);
                                                            Severity: Major
                                                            Found in outbound/hmail.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                                  return send_command('HELO', mx.bind_helo);
                                                              Severity: Major
                                                              Found in outbound/hmail.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                    return client_pool.release_client(socket, port, host, mx.bind, true);
                                                                Severity: Major
                                                                Found in outbound/hmail.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                                      return self.bounce(reason, { mx });
                                                                  Severity: Major
                                                                  Found in outbound/hmail.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                                if (!smtp_properties.tls) return auth_and_mail_phase(); // TLS not advertised by remote
                                                                    Severity: Major
                                                                    Found in outbound/hmail.js - About 30 mins to fix

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

                                                                      function sort_mx (mx_list) {
                                                                          const sorted = mx_list.sort((a,b) => a.priority - b.priority);
                                                                      
                                                                          // This isn't a very good shuffle but it'll do for now.
                                                                          for (let i=0,l=sorted.length-1; i<l; i++) {
                                                                      Severity: Minor
                                                                      Found in outbound/hmail.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

                                                                      for (const key in logger) {
                                                                          if (!/^log\w/.test(key)) continue;
                                                                          HMailItem.prototype[key] = (function (level) {
                                                                              return function () {
                                                                                  // pass the HMailItem instance to logger
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 4 hrs to fix
                                                                      connection.js on lines 1914..1926

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

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

                                                                                          recipients.forEach(rcpt => {
                                                                                              rcpt.dsn_action = 'failed';
                                                                                              rcpt.dsn_smtp_code = code;
                                                                                              rcpt.dsn_smtp_extc = extc;
                                                                                              rcpt.dsn_status = extc;
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 3 hrs to fix
                                                                      outbound/hmail.js on lines 718..725
                                                                      outbound/hmail.js on lines 756..763

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

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

                                                                                          recipients.forEach(rcpt => {
                                                                                              rcpt.dsn_action = 'delayed';
                                                                                              rcpt.dsn_smtp_code = code;
                                                                                              rcpt.dsn_smtp_extc = extc;
                                                                                              rcpt.dsn_status = extc;
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 3 hrs to fix
                                                                      outbound/hmail.js on lines 718..725
                                                                      outbound/hmail.js on lines 807..814

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

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

                                                                                      recipients.forEach(rcpt => {
                                                                                          rcpt.dsn_action = 'delayed';
                                                                                          rcpt.dsn_smtp_code = code;
                                                                                          rcpt.dsn_smtp_extc = extc;
                                                                                          rcpt.dsn_status = extc;
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 3 hrs to fix
                                                                      outbound/hmail.js on lines 756..763
                                                                      outbound/hmail.js on lines 807..814

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

                                                                      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

                                                                                  else if (err.code === 'NOMX') {
                                                                                      this.todo.rcpt_to.forEach(rcpt => {
                                                                                          this.extend_rcpt_with_dsn(rcpt, DSN.addr_bad_dest_system(`Nowhere to deliver mail to for domain: ${this.todo.domain}`));
                                                                                      });
                                                                                      this.bounce(`Nowhere to deliver mail to for domain: ${this.todo.domain}`);
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 238..256

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

                                                                      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 (err.code === dns.NXDOMAIN || err.code === dns.NOTFOUND) {
                                                                                      this.todo.rcpt_to.forEach(rcpt => {
                                                                                          this.extend_rcpt_with_dsn(rcpt, DSN.addr_bad_dest_system(`No Such Domain: ${this.todo.domain}`));
                                                                                      });
                                                                                      this.bounce(`No Such Domain: ${this.todo.domain}`);
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 244..256

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

                                                                      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 (bounce_recips.length) {
                                                                                      self.refcount++;
                                                                                      self.split_to_new_recipients(bounce_recips, "Some recipients rejected", hmail => {
                                                                                          self.discard();
                                                                                          hmail.bounce(`Some recipients failed: ${bounce_recips.join(', ')}`, { bounce_recips, mx });
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 635..641

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

                                                                      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 (fail_recips.length) {
                                                                                      self.refcount++;
                                                                                      self.split_to_new_recipients(fail_recips, "Some recipients temporarily failed", hmail => {
                                                                                          self.discard();
                                                                                          hmail.temp_fail(`Some recipients temp failed: ${fail_recips.join(', ')}`, { fail_recips, mx });
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 642..648

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

                                                                      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

                                                                                  else if (rcpt_to.dsn_code) {
                                                                                      if (/^5/.exec(rcpt_to.dsn_code)) {
                                                                                          dsn_action = 'failed';
                                                                                      }
                                                                                      else if (/^4/.exec(rcpt_to.dsn_code)) {
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 1171..1181

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

                                                                      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

                                                                                  else if (rcpt_to.dsn_smtp_code) {
                                                                                      if (/^5/.exec(rcpt_to.dsn_smtp_code)) {
                                                                                          dsn_action = 'failed';
                                                                                      }
                                                                                      else if (/^4/.exec(rcpt_to.dsn_smtp_code)) {
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                                                                      outbound/hmail.js on lines 1160..1181

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

                                                                      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

                                                                                              { exchange: mxlist[mx].exchange, priority: mxlist[mx].priority, port: mxlist[mx].port, using_lmtp: mxlist[mx].using_lmtp, family: 'A' }
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 1 hr to fix
                                                                      outbound/hmail.js on lines 277..277

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

                                                                      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

                                                                                              { exchange: mxlist[mx].exchange, priority: mxlist[mx].priority, port: mxlist[mx].port, using_lmtp: mxlist[mx].using_lmtp, family: 'AAAA' },
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 1 other location - About 1 hr to fix
                                                                      outbound/hmail.js on lines 278..278

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

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

                                                                                  hmail.todo.rcpt_to.forEach(rcpt => {
                                                                                      hmail.extend_rcpt_with_dsn(rcpt, DSN.sys_unspecified(`Error re-queueing some recipients: ${err}`));
                                                                                  });
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 55 mins to fix
                                                                      outbound/hmail.js on lines 677..679
                                                                      outbound/hmail.js on lines 1405..1407

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

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

                                                                                      self.todo.rcpt_to.forEach(rcpt => {
                                                                                          self.extend_rcpt_with_dsn(rcpt, DSN.proto_invalid_command(`Unrecognized response from upstream server: ${line}`));
                                                                                      });
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 55 mins to fix
                                                                      outbound/hmail.js on lines 1405..1407
                                                                      outbound/hmail.js on lines 1444..1446

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

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

                                                                                  hmail.todo.rcpt_to.forEach(rcpt => {
                                                                                      hmail.extend_rcpt_with_dsn(rcpt, DSN.sys_unspecified(`Error splitting to new recipients: ${err}`));
                                                                                  });
                                                                      Severity: Major
                                                                      Found in outbound/hmail.js and 2 other locations - About 55 mins to fix
                                                                      outbound/hmail.js on lines 677..679
                                                                      outbound/hmail.js on lines 1444..1446

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

                                                                      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

                                                                                      socket.once('secure', () => {
                                                                                          // Set this flag so we don't try STARTTLS again if it
                                                                                          // is incorrectly offered at EHLO once we are secured.
                                                                                          secured = true;
                                                                                          send_command(mx.using_lmtp ? 'LHLO' : 'EHLO', mx.bind_helo);
                                                                      Severity: Minor
                                                                      Found in outbound/hmail.js and 1 other location - About 40 mins to fix
                                                                      outbound/hmail.js on lines 613..618

                                                                      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

                                                                                          socket.once('secure', () => {
                                                                                              // Set this flag so we don't try STARTTLS again if it
                                                                                              // is incorrectly offered at EHLO once we are secured.
                                                                                              secured = true;
                                                                                              send_command(mx.using_lmtp ? 'LHLO' : 'EHLO', mx.bind_helo);
                                                                      Severity: Minor
                                                                      Found in outbound/hmail.js and 1 other location - About 40 mins to fix
                                                                      outbound/hmail.js on lines 586..591

                                                                      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

                                                                                      reason = `${code} ${(extc) ? `${extc} ` : ''}${response.join(' ')}`;
                                                                      Severity: Minor
                                                                      Found in outbound/hmail.js and 1 other location - About 35 mins to fix
                                                                      outbound/hmail.js on lines 735..735

                                                                      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

                                                                                          reason = `${code} ${(extc) ? `${extc} ` : ''}${response.join(' ')}`;
                                                                      Severity: Minor
                                                                      Found in outbound/hmail.js and 1 other location - About 35 mins to fix
                                                                      outbound/hmail.js on lines 785..785

                                                                      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