msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

Function parse has 53 lines of code (exceeds 25 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: Major
Found in rfc1869.js - About 2 hrs to fix

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

            if (cfg.cert) {
                if (Array.isArray(cfg.cert)) {
                    cfg.cert = cfg.cert[0];
                }
                cfg.cert = this.config.get(cfg.cert, 'binary');
    Severity: Major
    Found in outbound/tls.js and 1 other location - About 2 hrs to fix
    outbound/tls.js on lines 37..42

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

    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 (cfg.key) {
                if (Array.isArray(cfg.key)) {
                    cfg.key = cfg.key[0];
                }
                cfg.key = this.config.get(cfg.key, 'binary');
    Severity: Major
    Found in outbound/tls.js and 1 other location - About 2 hrs to fix
    outbound/tls.js on lines 48..53

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

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

    exports.get_sender_domain = function (connection) {
    
        const txn = connection?.transaction;
        if (!txn) return;
    
    
    Severity: Minor
    Found in plugins/dkim_sign.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 lookup_mx has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.lookup_mx = function lookup_mx (domain, cb) {
        const mxs = [];
    
        // Possible DNS errors
        // NODATA
    Severity: Minor
    Found in outbound/mx_lookup.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 connect has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function connect (port, host) {
        let conn_options = {};
        if (typeof port === 'object') {
            conn_options = port;
        }
    Severity: Major
    Found in tls_socket.js - About 2 hrs to fix

      Function respond has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          respond (code, msg, func) {
              let uuid = '';
              let messages;
      
              if (this.state === states.DISCONNECTED) {
      Severity: Major
      Found in connection.js - About 2 hrs to fix

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

                    case constants.denysoft:
                        this.respond(450, msg, () => {
                            this.msg_count.tempfail++;
                            this.transaction.msg_status = 'deferred';
                            this.reset_transaction(() => this.resume());
        Severity: Major
        Found in connection.js and 3 other locations - About 2 hrs to fix
        connection.js on lines 1773..1779
        connection.js on lines 1850..1856
        connection.js on lines 1864..1870

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

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

                    case constants.deny:
                        this.respond(550, msg, () => {
                            this.msg_count.reject++;
                            this.transaction.msg_status = 'rejected';
                            this.reset_transaction(() => this.resume());
        Severity: Major
        Found in connection.js and 3 other locations - About 2 hrs to fix
        connection.js on lines 1787..1793
        connection.js on lines 1850..1856
        connection.js on lines 1864..1870

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

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

                    case constants.deny:
                        this.respond(550, msg, () => {
                            this.msg_count.reject++;
                            this.transaction.msg_status = 'rejected';
                            this.reset_transaction(() =>  this.resume());
        Severity: Major
        Found in connection.js and 3 other locations - About 2 hrs to fix
        connection.js on lines 1773..1779
        connection.js on lines 1787..1793
        connection.js on lines 1864..1870

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

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

                    case constants.denysoft:
                        this.respond(450, msg, () => {
                            this.msg_count.tempfail++;
                            this.transaction.msg_status = 'deferred';
                            this.reset_transaction(() => this.resume());
        Severity: Major
        Found in connection.js and 3 other locations - About 2 hrs to fix
        connection.js on lines 1773..1779
        connection.js on lines 1787..1793
        connection.js on lines 1850..1856

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

        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 load_excludes has 51 lines of code (exceeds 25 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: Major
        Found in plugins/clamd.js - About 2 hrs to fix

          Function setup_http_listeners has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Server.setup_http_listeners = () => {
              if (!Server.http.cfg) return;
              if (!Server.http.cfg.listen) return;
          
              const listeners = Server.get_listen_addrs(Server.http.cfg, 80);
          Severity: Minor
          Found in server.js - About 2 hrs to fix

            Function attach has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                attach (socket) {
                    this.targetsocket = socket;
                    this.targetsocket.on('data', data => {
                        this.emit('data', data);
                    });
            Severity: Minor
            Found in tls_socket.js - About 2 hrs to fix

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

                  if (domains.length === 0) {
                      connection.loginfo(this, 'no domain(s) parsed from Message-ID headers');
                      transaction.results.add(this, { fail: 'Message-ID parseable' });
                      if (!this.cfg.reject.non_local_msgid) return next();
                      return next(DENY, `bounce with invalid Message-ID, I didn't send it.`);
              Severity: Major
              Found in plugins/bounce.js and 1 other location - About 2 hrs to fix
              plugins/bounce.js on lines 223..228

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

              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 (!matches.length) {
                      connection.loginfo(this, 'no Message-ID matches');
                      transaction.results.add(this, { fail: 'Message-ID' });
                      if (!this.cfg.reject.non_local_msgid) return next();
                      return next(DENY, `bounce without Message-ID in headers, unable to verify that I sent it`);
              Severity: Major
              Found in plugins/bounce.js and 1 other location - About 2 hrs to fix
              plugins/bounce.js on lines 237..242

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

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

              exports.load_tls_ini = (opts) => {
              
                  log.loginfo(`loading tls.ini`); // from ${this.config.root_path}`);
              
                  const cfg = exports.config.get('tls.ini', {
              Severity: Minor
              Found in tls_socket.js - About 1 hr to fix

                Function load_config_lists has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.load_config_lists = function () {
                    const plugin = this;
                
                    plugin.whitelist = {};
                    plugin.list = {};
                Severity: Minor
                Found in plugins/greylist.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 load_config has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    load_config () {
                        const tls_cfg = tls_socket.load_tls_ini({role: 'client'});
                        const cfg = JSON.parse(JSON.stringify(tls_cfg.outbound || {}));
                        cfg.redis = tls_cfg.redis; // Don't clone - contains methods
                
                
                Severity: Minor
                Found in outbound/tls.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

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

                    if (c.user) {
                        Server.lognotice(`Switching from current uid: ${process.getuid()}`);
                        process.setuid(c.user);
                        Server.lognotice(`New uid: ${process.getuid()}`);
                    }
                Severity: Major
                Found in server.js and 1 other location - About 1 hr to fix
                server.js on lines 606..610

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

                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