msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

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

exports.hook_data = (next, connection) => {
    const { server } = connection;
    if (server.cluster) {
        const { worker } = server.cluster;
        worker.send({event: 'process_title.message'});
Severity: Major
Found in plugins/process_title.js and 1 other location - About 3 hrs to fix
plugins/process_title.js on lines 182..190

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

exports.hook_rcpt = (next, connection) => {
    const { server } = connection;
    if (server.cluster) {
        const { worker } = server.cluster;
        worker.send({event: 'process_title.recipient'});
Severity: Major
Found in plugins/process_title.js and 1 other location - About 3 hrs to fix
plugins/process_title.js on lines 192..200

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

Function hook_init_master has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.hook_init_master = function (next, server) {
    server.notes.pt_connections = 0;
    server.notes.pt_concurrent = 0;
    server.notes.pt_cps_diff = 0;
    server.notes.pt_cps_max = 0;
Severity: Major
Found in plugins/process_title.js - About 2 hrs to fix

    File dkim_sign.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // dkim_signer
    // Implements DKIM core as per www.dkimcore.org
    
    const addrparser = require('address-rfc2822');
    const async      = require('async');
    Severity: Minor
    Found in plugins/dkim_sign.js - About 2 hrs to fix

      Function process_line has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          process_line (line) {
      
              if (this.state >= states.DISCONNECTING) {
                  if (logger.would_log(logger.LOGPROTOCOL)) {
                      this.logprotocol(`C: (after-disconnect): ${this.current_line}`, {'state': this.state});
      Severity: Major
      Found in connection.js - About 2 hrs to fix

        Function queue_outbound_respond has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            queue_outbound_respond (retval, msg) {
                if (!msg) msg = this.queue_msg(retval, msg) || 'Message Queued';
                this.store_queue_result(retval, msg);
                msg = `${msg} (${this.transaction.uuid})`;
                if (retval !== constants.ok) {
        Severity: Major
        Found in connection.js - About 2 hrs to fix

          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

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

              respond (code, msg, func) {
                  let uuid = '';
                  let messages;
          
                  if (this.state === states.DISCONNECTED) {
          Severity: Minor
          Found in connection.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 hook_unrecognized_command has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.hook_unrecognized_command = function (next, connection, params) {
              if (params[0] !== 'XCLIENT') return next();
          
              // XCLIENT is not allowed after transaction start
              if (connection?.transaction) {
          Severity: Major
          Found in plugins/xclient.js - About 2 hrs to fix

            Function log_if_level has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            logger.log_if_level = (level, key, plugin) => function () {
                if (logger.loglevel < logger[key]) { return; }
                let logobj = {
                    level,
                    uuid: '-',
            Severity: Major
            Found in logger.js - About 2 hrs to fix

              Function _graceful has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Server._graceful = shutdown => {
                  if (!Server.cluster && shutdown) {
                      ['outbound', 'cfreader', 'plugins'].forEach(module => {
                          process.emit('message', {event: `${module  }.shutdown`});
                      });
              Severity: Major
              Found in server.js - About 2 hrs to fix

                Function craft_hostid has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.craft_hostid = function (connection) {
                    const plugin = this;
                    const { transaction, remote } = connection ?? {};
                    if (!transaction || !remote) return null;
                
                
                Severity: Minor
                Found in plugins/greylist.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 load_default_opts has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.load_default_opts = () => {
                
                    const cfg = certsByHost['*'];
                
                    if (cfg.dhparam && typeof cfg.dhparam === 'string') {
                Severity: Minor
                Found in tls_socket.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 set has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    set (prop_str, val) {
                        if (arguments.length === 3) {
                            prop_str = `${arguments[0]}.${arguments[1]}`;
                            val = arguments[2];
                        }
                Severity: Minor
                Found in connection.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 hook_connect has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.hook_connect = function (next, connection) {
                    const cfg = this.config.get('messagesniffer.ini');
                    // Skip any private IP ranges
                    // Skip connection.transaction undefined
                    if (connection?.remote?.is_private || !connection?.transaction) return next();
                Severity: Major
                Found in plugins/messagesniffer.js - About 2 hrs to fix

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language