haraka/haraka-plugin-spf

View on GitHub

Showing 51 of 68 total issues

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

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

      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

        Avoid deeply nested control flow statements.
        Open

                    if (this.ipaddr.match(range, cidr)) {
                      this.log_debug(
                        `mech_mx: ${this.ip} => ${address}/${cidr}: MATCH!`,
                      )
                      return this.return_const(qualifier)
        Severity: Major
        Found in lib/spf.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

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

            Avoid too many return statements within this function.
            Open

                  if (result && result !== this.SPF_NONE) return result
            Severity: Major
            Found in lib/spf.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return this.SPF_PERMERROR
              Severity: Major
              Found in lib/spf.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return this.return_const(qualifier)
                Severity: Major
                Found in lib/spf.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 (pending === 0) return this.SPF_NONE
                    Severity: Major
                    Found in lib/spf.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return this.SPF_PERMERROR
                      Severity: Major
                      Found in lib/spf.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return this.SPF_PERMERROR
                        Severity: Major
                        Found in lib/spf.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              if (plugin.cfg.relay.context === 'sender') return ch_cb(null, result)
                          Severity: Major
                          Found in index.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return this.SPF_NONE
                            Severity: Major
                            Found in lib/spf.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  if (timeout) return
                              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, `${msgpre} SPF Permanent Error`)
                                  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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language