haraka/haraka-plugin-bounce

View on GitHub

Showing 18 of 22 total issues

Function bounce_spf has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.bounce_spf = function (next, connection) {
  if (!this.cfg.check.bounce_spf) return next()
  if (!this.has_null_sender(connection)) return next()

  const txn = connection?.transaction
Severity: Major
Found in index.js - About 2 hrs to fix

    File index.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // bounce tests
    const tlds = require('haraka-tld')
    const { SPF } = require('haraka-plugin-spf')
    const net_utils = require('haraka-net-utils')
    
    
    Severity: Minor
    Found in index.js - About 2 hrs to fix

      Function non_local_msgid has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.non_local_msgid = function (next, connection) {
        if (!this.cfg.check.non_local_msgid) return next()
        if (!this.has_null_sender(connection)) return next()
      
        const transaction = connection?.transaction
      Severity: Minor
      Found in index.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 non_local_msgid has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.non_local_msgid = function (next, connection) {
        if (!this.cfg.check.non_local_msgid) return next()
        if (!this.has_null_sender(connection)) return next()
      
        const transaction = connection?.transaction
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function bounce_spf has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.bounce_spf = function (next, connection) {
          if (!this.cfg.check.bounce_spf) return next()
          if (!this.has_null_sender(connection)) return next()
        
          const txn = connection?.transaction
        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

        Function single_recipient has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.single_recipient = function (next, connection) {
          if (!this?.cfg?.check?.single_recipient) return next()
          if (!this.has_null_sender(connection)) return next()
          const { transaction, relaying, remote } = connection
        
        
        Severity: Minor
        Found in index.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

              if (!this.cfg.reject.non_local_msgid) 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

                if (!this.cfg.reject.single_recipient) 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, 'bounce with non-empty Return-Path (RFC 3834)')
                Severity: Major
                Found in index.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if (!this.cfg.reject.non_local_msgid) return next()
                  Severity: Major
                  Found in index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              if (!this.cfg.reject.bounce_spf) return run_cb()
                    Severity: Major
                    Found in index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return next(DENY, `bounce with invalid Message-ID, I didn't send it.`)
                      Severity: Major
                      Found in index.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return next(
                              DENY,
                              `bounce Message-ID without valid domain, I didn't send it.`,
                            )
                        Severity: Major
                        Found in index.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return next(
                                DENY,
                                `bounce without Message-ID in headers, unable to verify that I sent it`,
                              )
                          Severity: Major
                          Found in index.js - About 30 mins to fix

                            Function single_recipient has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            exports.single_recipient = function (next, connection) {
                              if (!this?.cfg?.check?.single_recipient) return next()
                              if (!this.has_null_sender(connection)) return next()
                              const { transaction, relaying, remote } = connection
                            
                            
                            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

                            Function bad_rcpt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            exports.bad_rcpt = function (next, connection) {
                              if (!this.cfg.check.bad_rcpt) return next()
                              if (!this.has_null_sender(connection)) return next()
                              if (!this.cfg.invalid_addrs) return next()
                            
                            
                            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

                            Function find_received_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function find_received_headers(ips, body, connection, self) {
                              if (!body) return
                              let match
                              while ((match = received_re.exec(body.bodytext))) {
                                const ip = match[1]
                            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

                            Severity
                            Category
                            Status
                            Source
                            Language