msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

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

    constructor (opts = {}) {
        super();
        this.uuid = utils.uuid();
        this.connect_timeout = parseInt(opts.connect_timeout) || 30;
        this.socket = opts.socket || line_socket.connect(opts.port, opts.host);
Severity: Major
Found in smtp_client.js - About 5 hrs to fix

    Function run_next_hook has a Cognitive Complexity of 37 (exceeds 5 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: Minor
    Found in plugins.js - About 5 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 helo.checks.js has 399 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    // Check various bits of the HELO string
    
    const tlds      = require('haraka-tld');
    const dns       = require('dns');
    Severity: Minor
    Found in plugins/helo.checks.js - About 5 hrs to fix

      Function end has 134 lines of code (exceeds 25 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: Major
      Found in dkim.js - About 5 hrs to fix

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

            cmd_ehlo (line) {
                const results = (String(line)).split(/ +/);
                const host = results[0];
                if (!host) {
                    return this.respond(501, "EHLO requires domain/address - see RFC-2821 4.1.1.1");
        Severity: Major
        Found in connection.js and 1 other location - About 5 hrs to fix
        connection.js on lines 1270..1283

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

        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

            cmd_helo (line) {
                const results = (String(line)).split(/ +/);
                const host = results[0];
                if (!host) {
                    return this.respond(501, "HELO requires domain/address - see RFC-2821 4.1.1.1");
        Severity: Major
        Found in connection.js and 1 other location - About 5 hrs to fix
        connection.js on lines 1284..1297

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

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

        exports.parse = (type, line, strict) => {
            let params = [];
            line = (new String(line)).replace(/\s*$/, '');
            if (type === 'mail') {
                line = line.replace(strict ? /from:/i : /from:\s*/i, '');
        Severity: Minor
        Found in rfc1869.js - About 5 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 smtp_client.js has 373 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        // SMTP client object and class. This allows every part of the client
        // protocol to be hooked for different levels of control, such as
        // smtp_forward and smtp_proxy queue plugins.
        // It can use HostPool to get a connection to a pool of
        Severity: Minor
        Found in smtp_client.js - About 4 hrs to fix

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

          exports.hook_data_post = function (next, connection) {
              const plugin = this;
              if (!plugin.should_check(connection)) return next();
          
              const txn = connection.transaction;
          Severity: Major
          Found in plugins/clamd.js - About 4 hrs to fix

            Function process_line has a Cognitive Complexity of 31 (exceeds 5 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: Minor
            Found in connection.js - About 4 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 send_email has a Cognitive Complexity of 31 (exceeds 5 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: Minor
            Found in outbound/index.js - About 4 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

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

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

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

            exports.hook_data_post = function (next, connection) {
                if (!connection?.transaction) return next()
            
                const plugin = this;
                const tmpfile = plugin.get_tmp_file(connection.transaction);
            Severity: Major
            Found in plugins/avg.js - About 4 hrs to fix

              Function constructor has 109 lines of code (exceeds 25 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: Major
              Found in dkim.js - About 4 hrs to fix

                Function handle_buf has 106 lines of code (exceeds 25 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: Major
                Found in dkim.js - About 4 hrs to fix

                  Function try_next_host has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function try_next_host () {
                          let connected = false;
                          if (!hosts.length) {
                              if (txn) txn.results.add(plugin, {err: 'connecting' });
                              if (!plugin.cfg.reject.error) return next();
                  Severity: Major
                  Found in plugins/clamd.js - About 4 hrs to fix

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

                            case 'helo':
                                if (!connection.notes.delay_deny_pre) {
                                    connection.notes.delay_deny_pre = [];
                                }
                                connection.notes.delay_deny_pre.push(params);
                    Severity: Major
                    Found in plugins/delay_deny.js and 1 other location - About 4 hrs to fix
                    plugins/delay_deny.js on lines 80..89

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

                    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

                            case 'rcpt_ok':
                                if (!transaction.notes.delay_deny_pre) {
                                    transaction.notes.delay_deny_pre = [];
                                }
                                transaction.notes.delay_deny_pre.push(params);
                    Severity: Major
                    Found in plugins/delay_deny.js and 1 other location - About 4 hrs to fix
                    plugins/delay_deny.js on lines 67..76

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

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

                    exports.get_client_plugin = (plugin, connection, c, callback) => {
                        // c = config
                        // Merge in authentication settings from smtp_forward/proxy.ini if present
                        // FIXME: config.auth could be changed when API isn't frozen
                        if (c.auth_type || c.auth_user || c.auth_pass) {
                    Severity: Major
                    Found in smtp_client.js - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language