haraka/haraka-plugin-access

View on GitHub
index.js

Summary

Maintainability
F
3 days
Test Coverage

Function any_whitelist has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  connection,
  hook,
  params,
  domain,
  org_domain,
Severity: Minor
Found in index.js - About 35 mins to fix

    Avoid too many return statements within this function.
    Open

          return params
    Severity: Major
    Found in index.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return
      Severity: Major
      Found in index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              if (net_utils.is_ip_literal(params)) return
        Severity: Major
        Found in index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return next(DENY, 'You are not welcome here.')
          Severity: Major
          Found in index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return next()
            Severity: Major
            Found in index.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return next(DENY, 'Email from that domain is not accepted here.')
              Severity: Major
              Found in index.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return next()
                Severity: Major
                Found in index.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        if (params && params[0]) return params[0].host
                  Severity: Major
                  Found in index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return next(DENY, `${rcpt_to} ${this.cfg.deny_msg.rcpt}`)
                    Severity: Major
                    Found in index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return next()
                      Severity: Major
                      Found in index.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return next()
                        Severity: Major
                        Found in index.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return next(DENY, `${mail_from} ${this.cfg.deny_msg.mail}`)
                          Severity: Major
                          Found in index.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return next(DENY, `${rcpt_to} ${this.cfg.deny_msg.rcpt}`)
                            Severity: Major
                            Found in index.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return next(DENY, `${mail_from} ${this.cfg.deny_msg.mail}`)
                              Severity: Major
                              Found in index.js - About 30 mins to fix

                                Function register has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
                                Open

                                exports.register = function () {
                                  this.init_config() // init this.cfg
                                  this.init_lists()
                                  this.load_access_ini() // update with *.ini settings
                                
                                
                                Severity: Minor
                                Found in index.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

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

                                  if (this.in_list('black', 'mail', mail_from)) {
                                    connection.transaction.results.add(this, { fail: file, emit: true })
                                    return next(DENY, `${mail_from} ${this.cfg.deny_msg.mail}`)
                                  }
                                Severity: Major
                                Found in index.js and 3 other locations - About 2 hrs to fix
                                index.js on lines 331..334
                                index.js on lines 373..376
                                index.js on lines 379..382

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

                                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

                                  if (this.in_re_list('black', 'mail', mail_from)) {
                                    connection.transaction.results.add(this, { fail: file, emit: true })
                                    return next(DENY, `${mail_from} ${this.cfg.deny_msg.mail}`)
                                  }
                                Severity: Major
                                Found in index.js and 3 other locations - About 2 hrs to fix
                                index.js on lines 324..327
                                index.js on lines 373..376
                                index.js on lines 379..382

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

                                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

                                  if (this.in_list('black', 'rcpt', rcpt_to)) {
                                    connection.transaction.results.add(this, { fail: file, emit: true })
                                    return next(DENY, `${rcpt_to} ${this.cfg.deny_msg.rcpt}`)
                                  }
                                Severity: Major
                                Found in index.js and 3 other locations - About 2 hrs to fix
                                index.js on lines 324..327
                                index.js on lines 331..334
                                index.js on lines 379..382

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

                                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

                                  if (this.in_re_list('black', 'rcpt', rcpt_to)) {
                                    connection.transaction.results.add(this, { fail: file, emit: true })
                                    return next(DENY, `${rcpt_to} ${this.cfg.deny_msg.rcpt}`)
                                  }
                                Severity: Major
                                Found in index.js and 3 other locations - About 2 hrs to fix
                                index.js on lines 324..327
                                index.js on lines 331..334
                                index.js on lines 373..376

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

                                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.in_list('domain', 'any', org_domain)) {
                                    connection.results.add(this, {
                                      fail: `${file}(${org_domain})`,
                                      blacklist: true,
                                      emit: true,
                                Severity: Major
                                Found in index.js and 1 other location - About 1 hr to fix
                                index.js on lines 431..438

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

                                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.in_list('domain', 'any', hdr_dom)) {
                                    connection.results.add(this, {
                                      fail: `${file}(${hdr_dom})`,
                                      blacklist: true,
                                      emit: true,
                                Severity: Major
                                Found in index.js and 1 other location - About 1 hr to fix
                                index.js on lines 218..225

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

                                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

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

                                  if (!this.cfg.check[phase]) {
                                    this.logdebug(this, `skipping ${this.cfg[type][phase]}`)
                                    return
                                  }
                                Severity: Major
                                Found in index.js and 1 other location - About 1 hr to fix
                                index.js on lines 517..520

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

                                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

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

                                  if (!this.cfg.check[phase]) {
                                    this.logdebug(this, `skipping ${this.cfg[type][phase]}`)
                                    return
                                  }
                                Severity: Major
                                Found in index.js and 1 other location - About 1 hr to fix
                                index.js on lines 470..473

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

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

                                  if (rcpt_cfg && rcpt_cfg.general && rcpt_cfg.general.deny_msg) {
                                    this.cfg.deny_msg.rcpt = rcpt_cfg.general.deny_msg
                                  }
                                Severity: Major
                                Found in index.js and 2 other locations - About 55 mins to fix
                                index.js on lines 114..116
                                index.js on lines 122..124

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

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

                                  if (mf_cfg && mf_cfg.general && mf_cfg.general.deny_msg) {
                                    this.cfg.deny_msg.mail = mf_cfg.general.deny_msg
                                  }
                                Severity: Major
                                Found in index.js and 2 other locations - About 55 mins to fix
                                index.js on lines 118..120
                                index.js on lines 122..124

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

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

                                  if (rdns_cfg && rdns_cfg.general && rdns_cfg.general.deny_msg) {
                                    this.cfg.deny_msg.conn = rdns_cfg.general.deny_msg
                                  }
                                Severity: Major
                                Found in index.js and 2 other locations - About 55 mins to fix
                                index.js on lines 114..116
                                index.js on lines 118..120

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

                                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 (!hdr_addr) {
                                    connection.transaction.results.add(this, {
                                      fail: `data(unparsable_from:${hdr_from})`,
                                    })
                                    return next()
                                Severity: Minor
                                Found in index.js and 1 other location - About 45 mins to fix
                                index.js on lines 418..423

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

                                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 (!hdr_dom) {
                                    connection.transaction.results.add(this, {
                                      fail: `data(no_od_from:${hdr_addr})`,
                                    })
                                    return next()
                                Severity: Minor
                                Found in index.js and 1 other location - About 45 mins to fix
                                index.js on lines 410..415

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

                                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

                                There are no issues that match your filters.

                                Category
                                Status