msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

Avoid too many return statements within this function.
Open

                    return this.result('verification error', 'invalid');
Severity: Major
Found in dkim.js - About 30 mins to fix

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

        if (!this.dest.domains) {
            transaction.results.add(this, {skip: 'relay_dest_domain(config)'});
            return next();
        }
    Severity: Minor
    Found in plugins/relay.js and 1 other location - About 30 mins to fix
    plugins/helo.checks.js on lines 292..295

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

    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

    Avoid too many return statements within this function.
    Open

            if (!this.fields.d) return this.result('domain missing', 'invalid');
    Severity: Major
    Found in dkim.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return this.result(`signature expired`, 'invalid');
      Severity: Major
      Found in dkim.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                    return this.result('inapplicable key', 'invalid');
        Severity: Major
        Found in dkim.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                                          return this.result('i/d selector domain mismatch (t=s)', 'invalid')
          Severity: Major
          Found in dkim.js - About 30 mins to fix

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

                                        if (i.toLowerCase() !== this.fields.d.toLowerCase()) {
                                            return this.result('i/d selector domain mismatch (t=s)', 'invalid')
                                        }
            Severity: Minor
            Found in dkim.js and 1 other location - About 30 mins to fix
            dkim.js on lines 150..152

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

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

            exports.hook_rcpt = function (next, connection, params) {
                const txn = connection?.transaction;
                if (!txn) return;
            
                const rcpt = params[0];
            Severity: Minor
            Found in plugins/rcpt_to.in_host_list.js - About 25 mins 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 get_mx has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_mx = function (next, hmail, domain) {
            
                const qw = hmail.todo.notes.get('queue.wants')
                if (qw && qw !== 'smtp_forward') return next()
            
            
            Severity: Minor
            Found in plugins/queue/smtp_forward.js - About 25 mins 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 select_auth_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.select_auth_method = function (next, connection, method) {
                const split = method.split(/\s+/);
                method = split.shift().toUpperCase();
                if (!connection.notes.allowed_auth_methods) return next();
                if (!connection.notes.allowed_auth_methods.includes(method)) return next();
            Severity: Minor
            Found in plugins/auth/auth_base.js - About 25 mins 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 ip_in_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.ip_in_list = function (ip) {
            
                if (!this.whitelist) return false;
            
                const ipobj = ipaddr.parse(ip);
            Severity: Minor
            Found in plugins/early_talker.js - About 25 mins 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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.register = function () {
            
                this.load_relay_ini();             // plugin.cfg = { }
            
                if (this.cfg.relay.acl) {
            Severity: Minor
            Found in plugins/relay.js - About 25 mins 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_mail has a Cognitive Complexity of 6 (exceeds 5 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: Minor
            Found in plugins/mail_from.is_resolvable.js - About 25 mins 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.hook_data_post = function (next, connection) {
                const txn = connection?.transaction;
                if (!txn) return next();
            
                const verifier = new DKIMVerifyStream(this.cfg, (err, result, results) => {
            Severity: Minor
            Found in plugins/dkim_verify.js - About 25 mins 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_queue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.hook_queue = function (next, connection) {
                const plugin = this;
            
                const txn = connection?.transaction;
                if (!txn) return next();
            Severity: Minor
            Found in plugins/queue/qmail-queue.js - About 25 mins 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 close has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                close (cb) {
                    const self = this;
                    if (cb) this.once('close', cb);
            
                    if (this.closed || 'number' !== typeof this.fd) {
            Severity: Minor
            Found in outbound/fsync_writestream.js - About 25 mins 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 dynamic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.dynamic = function (next, connection, helo) {
            
                if (this.should_skip(connection, 'dynamic')) return next();
            
                // Skip if no dots or an IP literal or address
            Severity: Minor
            Found in plugins/helo.checks.js - About 25 mins 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 forward_dns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.forward_dns = function (next, connection, helo) {
            
                if (this.should_skip(connection, 'forward_dns')) return next();
                if (!this.cfg.check.valid_hostname) {
                    connection.results.add(this, {err: 'forward_dns(valid_hostname disabled)'});
            Severity: Minor
            Found in plugins/helo.checks.js - About 25 mins 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_mail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.hook_mail = function (next, connection, params) {
                if (!connection.transaction) return next();
            
                const mail_from = params[0];
            
            
            Severity: Minor
            Found in plugins/greylist.js - About 25 mins 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 process_skip_rules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.process_skip_rules = function (connection) {
                const cr = connection.results;
            
                const skip_cfg = this.cfg.skip;
                if (skip_cfg) {
            Severity: Minor
            Found in plugins/greylist.js - About 25 mins 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

            Severity
            Category
            Status
            Source
            Language