haraka/haraka-plugin-spf

View on GitHub

Showing 68 of 68 total issues

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

    try {
      const addrs = await dns.resolve(exists)
      this.log_debug(`mech_exists: ${exists} result=${addrs.join(',')}`)
      return this.return_const(qualifier)
    } catch (err) {
Severity: Major
Found in lib/spf.js and 1 other location - About 2 hrs to fix
lib/spf.js on lines 421..433

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

    try {
      addrs = await dns[resolve_method](domain)
    } catch (err) {
      this.log_debug(`mech_a: ${err}`)
      switch (err.code) {
Severity: Major
Found in lib/spf.js and 1 other location - About 2 hrs to fix
lib/spf.js on lines 377..391

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

  async mech_ptr(qualifier, args) {
    this.count++
    let dm
    let domain = this.domain
    if (args && (dm = /^:([^/ ]+)/.exec(args))) {
Severity: Major
Found in lib/spf.js - About 2 hrs to fix

    Function helo_spf has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.helo_spf = async function (next, connection, helo) {
      const plugin = this
    
      // bypass auth'ed or relay'ing hosts if told to
      const skip_reason = this.skip_hosts(connection)
    Severity: Minor
    Found in index.js - About 1 hr to fix

      Function return_results has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.return_results = function (
        next,
        connection,
        spf,
        scope,
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function ch_cb has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function ch_cb(err, result, ip) {
            if (timer) clearTimeout(timer)
            if (timeout) return
            if (err) {
              connection.logerror(plugin, err)
        Severity: Minor
        Found in index.js - About 1 hr to fix

          Function load_spf_ini has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.load_spf_ini = function () {
            this.nu = net_utils // so tests can set public_ip
            this.SPF = SPF
          
            this.cfg = this.config.get(
          Severity: Minor
          Found in index.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

              case spf.SPF_TEMPERROR:
                if (this.cfg[defer][`${scope}_temperror`]) {
                  return next(DENYSOFT, `${msgpre} SPF Temporary Error`)
                }
                return next()
          Severity: Major
          Found in index.js and 1 other location - About 1 hr to fix
          index.js on lines 334..338

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

          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 spf.SPF_PERMERROR:
                if (this.cfg[deny][`${scope}_permerror`]) {
                  return next(DENY, `${msgpre} SPF Permanent Error`)
                }
                return next()
          Severity: Major
          Found in index.js and 1 other location - About 1 hr to fix
          index.js on lines 329..333

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

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

            async mech_ip(qualifier, args) {
              const cidr = args.substr(1)
              const match = /^([^/ ]+)(?:\/(\d+))?$/.exec(cidr)
              if (!match) return this.SPF_NONE
          
          
          Severity: Minor
          Found in lib/spf.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 mech_include has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async mech_include(qualifier, args) {
              const domain = args.substr(1)
              // Avoid circular references
              if (this.been_there[domain]) {
                this.log_debug(`circular reference detected: ${domain}`)
          Severity: Minor
          Found in lib/spf.js - About 1 hr to fix

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

                if (this.cfg.main[`${phase}_softfail_reject`]) {
                  this.cfg.deny[`${phase}_softfail`] = true
                }
            Severity: Major
            Found in index.js and 3 other locations - About 1 hr to fix
            index.js on lines 69..71
            index.js on lines 72..74
            index.js on lines 75..77

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

            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.cfg.main[`${phase}_permerror_reject`]) {
                  this.cfg.deny[`${phase}_permerror`] = true
                }
            Severity: Major
            Found in index.js and 3 other locations - About 1 hr to fix
            index.js on lines 66..68
            index.js on lines 69..71
            index.js on lines 72..74

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

            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.cfg.main[`${phase}_fail_reject`]) {
                  this.cfg.deny[`${phase}_fail`] = true
                }
            Severity: Major
            Found in index.js and 3 other locations - About 1 hr to fix
            index.js on lines 66..68
            index.js on lines 72..74
            index.js on lines 75..77

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

            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.cfg.main[`${phase}_temperror_defer`]) {
                  this.cfg.defer[`${phase}_temperror`] = true
                }
            Severity: Major
            Found in index.js and 3 other locations - About 1 hr to fix
            index.js on lines 66..68
            index.js on lines 69..71
            index.js on lines 75..77

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

            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

              const timer = setTimeout(() => {
                timeout = true
                connection.loginfo(plugin, 'timeout')
                next()
              }, plugin.cfg.lookup_timeout * 1000)
            Severity: Minor
            Found in index.js and 1 other location - About 55 mins to fix
            index.js on lines 116..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

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

              const timer = setTimeout(() => {
                timeout = true
                connection.loginfo(plugin, 'timeout')
                next()
              }, plugin.cfg.lookup_timeout * 1000)
            Severity: Minor
            Found in index.js and 1 other location - About 55 mins to fix
            index.js on lines 201..205

            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

            Function helo_spf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.helo_spf = async function (next, connection, helo) {
              const plugin = this
            
              // bypass auth'ed or relay'ing hosts if told to
              const skip_reason = this.skip_hosts(connection)
            Severity: Minor
            Found in index.js - About 55 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 log_result has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            exports.log_result = function (connection, scope, host, mfrom, result, ip) {
            Severity: Minor
            Found in index.js - About 45 mins to fix

              Function return_results has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                next,
                connection,
                spf,
                scope,
                result,
              Severity: Minor
              Found in index.js - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language