msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (this.cfg.check.private_ip == false && connection.remote.is_private) {
        if (this.cfg.check.local_ip == true && connection.remote.is_local) {
            // local IPs are included in private IPs
        }
        else {
Severity: Major
Found in plugins/spamassassin.js and 1 other location - About 3 hrs to fix
plugins/clamd.js on lines 342..350

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

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 (this.cfg.check.private_ip == false && connection.remote.is_private) {
        if (this.cfg.check.local_ip == true && connection.remote.is_local) {
            // local IPs are included in private IPs
        }
        else {
Severity: Major
Found in plugins/clamd.js and 1 other location - About 3 hrs to fix
plugins/spamassassin.js on lines 373..381

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

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 _process_data has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _process_data () {
        // We *must* detect disconnected connections here as the state
        // only transitions to states.CMD in the respond function below.
        // Otherwise if multiple commands are pipelined and then the
        // connection is dropped; we'll end up in the function forever.
Severity: Major
Found in connection.js - About 3 hrs to fix

    File messagesniffer.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // messagesniffer
    
    const fs = require('fs');
    const net = require('net');
    const plugin = exports;
    Severity: Minor
    Found in plugins/messagesniffer.js - About 3 hrs 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

        File spamassassin.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        // Call spamassassin via spamd
        
        const sock  = require('./line_socket');
        const utils = require('haraka-utils');
        Severity: Minor
        Found in plugins/spamassassin.js - About 3 hrs to fix

          Function hook_mail has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.hook_mail = function (next, connection, params) {
              const plugin    = this;
              const mail_from = params[0];
              const txn       = connection?.transaction;
              if (!txn) return next();
          Severity: Major
          Found in plugins/mail_from.is_resolvable.js - About 3 hrs to fix

            Function constructor has 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                constructor (client, server, cfg) {
                    this.client = client;
                    this.server = server;
                    this.cfg = cfg;
            
            
            Severity: Major
            Found in connection.js - About 3 hrs to fix

              Function hook_deny has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.hook_deny = function (next, connection, params) {
                  /* params
                  ** [0] = plugin return value (DENY or DENYSOFT)
                  ** [1] = plugin return message
                  */
              Severity: Minor
              Found in plugins/delay_deny.js - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      const asArray = cfg.cert.map(certFileName => {
                          if (!certFileName) return;
                          const cert = this.config.get(certFileName, 'binary');
                          if (!cert) {
                              log.logerror(`tls cert ${path.join(this.config.root_path, certFileName)} could not be loaded.`);
              Severity: Major
              Found in tls_socket.js and 1 other location - About 3 hrs to fix
              tls_socket.js on lines 380..387

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

              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

                      const asArray = cfg.key.map(keyFileName => {
                          if (!keyFileName) return;
                          const key = this.config.get(keyFileName, 'binary');
                          if (!key) {
                              log.logerror(`tls key ${path.join(this.config.root_path, keyFileName)} could not be loaded.`);
              Severity: Major
              Found in tls_socket.js and 1 other location - About 3 hrs to fix
              tls_socket.js on lines 392..399

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

              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 end has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                  end () {
                      if (this.run_cb) return;
              
                      const bh = this.bh.digest('base64');
                      this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`);
              Severity: Minor
              Found in dkim.js - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              File clamd.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              // clamd
              
              const sock = require('./line_socket');
              const utils = require('haraka-utils');
              
              
              Severity: Minor
              Found in plugins/clamd.js - About 3 hrs to fix

                Function run_next_hook has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                plugins.run_next_hook = (hook, object, params) => {
                    if (client_disconnected(object) && !is_required_hook(hook)) {
                        object.logdebug(`aborting ${hook} hook`);
                        return;
                    }
                Severity: Major
                Found in plugins.js - About 3 hrs to fix

                  Function send_email has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.send_email = function () {
                  
                      if (arguments.length === 2) {
                          logger.logdebug("[outbound] Sending email as a transaction");
                          return this.send_trans_email(arguments[0], arguments[1]);
                  Severity: Major
                  Found in outbound/index.js - About 3 hrs to fix

                    Function load_excludes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.load_excludes = function () {
                    
                        this.loginfo('Loading excludes file');
                        const list = this.config.get('clamd.excludes','list', () => {
                            this.load_excludes();
                    Severity: Minor
                    Found in plugins/clamd.js - About 3 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function set_temp_fail_intervals has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.set_temp_fail_intervals = function () {
                        // Set the outbound temp fail intervals (retry times) using the following rules:
                        //   1) temp_fail_intervals takes precedence over maxTempFailures if both are specified
                        //   2) if temp_fail_intervals is not specified or is illegally specified, then initialize
                        //      it with the equivalent times of maxTempFailures using the original 2^N formula
                    Severity: Minor
                    Found in outbound/config.js - About 3 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function onCapabilitiesOutbound has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.onCapabilitiesOutbound = (smtp_client, secured, connection, config, on_secured) => {
                        for (const line in smtp_client.response) {
                            if (/^XCLIENT/.test(smtp_client.response[line])) {
                                if (!smtp_client.xclient) {
                                    smtp_client.send_command('XCLIENT', `ADDR=${connection.remote.ip}`);
                    Severity: Minor
                    Found in smtp_client.js - About 3 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function hook_data_post has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.hook_data_post = function (next, connection) {
                    
                        if (this.should_skip(connection)) return next();
                    
                        const txn  = connection.transaction;
                    Severity: Major
                    Found in plugins/spamassassin.js - About 3 hrs to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language