msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

File connection.js has 1689 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
// a single connection

// node.js built-in libs
const dns         = require('dns');
Severity: Major
Found in connection.js - About 4 days to fix

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

            handle_buf (buf) {
                const self = this;
                // Abort any further processing if the headers
                // did not contain any DKIM-Signature fields.
                if (this._in_body && this._no_signatures_found) {
        Severity: Minor
        Found in dkim.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

        File tls_socket.js has 583 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        /*--------------------------------------------------------------------------*/
        /* Obtained and modified from http://js.5sh.net/starttls.js on 8/18/2011.   */
        /*--------------------------------------------------------------------------*/
        
        
        Severity: Major
        Found in tls_socket.js - About 1 day to fix

          Connection has 64 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Connection {
              constructor (client, server, cfg) {
                  this.client = client;
                  this.server = server;
                  this.cfg = cfg;
          Severity: Major
          Found in connection.js - About 1 day to fix

            File server.js has 540 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            // smtp network server
            
            const daemon      = require('daemon');
            const fs          = require('fs');
            Severity: Major
            Found in server.js - About 1 day to fix

              File dkim.js has 511 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              'use strict';
              
              const crypto = require('crypto');
              const dns    = require('dns');
              const { Stream } = require('stream');
              Severity: Major
              Found in dkim.js - About 1 day to fix

                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

                  Function constructor has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                  Open

                      constructor (header, header_idx, cb, opts) {
                          this.cb = cb;
                          this.sig = header;
                          this.sig_md5 = md5(header);
                          this.run_cb = false;
                  Severity: Minor
                  Found in dkim.js - About 7 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 plugins.js has 488 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  'use strict';
                  // load all defined plugins
                  
                  // node built-ins
                  const fs          = require('fs');
                  Severity: Minor
                  Found in plugins.js - About 7 hrs to fix

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

                    exports.hook_data_post = function (next, connection) {
                        const cfg = this.config.get('messagesniffer.ini');
                        const txn = connection?.transaction;
                        if (!txn) return next();
                    
                    
                    Severity: Major
                    Found in plugins/messagesniffer.js - About 7 hrs to fix

                      Function log_if_level has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                      Open

                      logger.log_if_level = (level, key, plugin) => function () {
                          if (logger.loglevel < logger[key]) { return; }
                          let logobj = {
                              level,
                              uuid: '-',
                      Severity: Minor
                      Found in logger.js - About 7 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 greylist.js has 457 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      // Greylisting plugin for Haraka
                      
                      // version 0.1.4
                      
                      // node builtins
                      Severity: Minor
                      Found in plugins/greylist.js - About 7 hrs to fix

                        Function _process_data has a Cognitive Complexity of 45 (exceeds 5 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: Minor
                        Found in connection.js - About 6 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 a Cognitive Complexity of 43 (exceeds 5 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: Minor
                        Found in plugins/xclient.js - About 6 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

                                try {
                                    results = rfc1869.parse('mail', line, this.cfg.main.strict_rfc1869 && !this.relaying);
                                }
                                catch (err) {
                                    this.errors++;
                        Severity: Major
                        Found in connection.js and 1 other location - About 6 hrs to fix
                        connection.js on lines 1400..1418

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

                        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

                                try {
                                    results = rfc1869.parse('rcpt', line, this.cfg.main.strict_rfc1869 && !this.relaying);
                                }
                                catch (err) {
                                    this.errors++;
                        Severity: Major
                        Found in connection.js and 1 other location - About 6 hrs to fix
                        connection.js on lines 1336..1354

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

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

                        exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
                            if (!hosts || (hosts && !hosts.length)) return cb(false);
                            if (typeof hosts !== 'object') {
                                hosts = [ hosts ];
                            }
                        Severity: Major
                        Found in plugins/auth/auth_proxy.js - About 6 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language