haraka/haraka-plugin-spf

View on GitHub

Showing 51 of 68 total issues

Function check_host has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

  async check_host(ip, domain, mail_from) {
    domain = domain.toLowerCase()
    mail_from = mail_from ? mail_from.toLowerCase() : `postmaster@${domain}`
    this.ipaddr = ipaddr.parse(ip)
    this.ip_ver = this.ipaddr.kind()
Severity: Minor
Found in lib/spf.js - About 1 day 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

File spf.js has 562 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'
// spf

const dns = require('node:dns/promises')
const net = require('node:net')
Severity: Major
Found in lib/spf.js - About 1 day to fix

    Function mech_mx has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

      async mech_mx(qualifier, args) {
        this.count++
        // Parse any arguments
        let cm
        let cidr4
    Severity: Minor
    Found in lib/spf.js - About 6 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 expand_macros has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

      expand_macros(str) {
        const macro = /%{([slodipvh])((?:(?:\d+)?r?)?)?([-.+,/_=])?}/gi
        let match
        while ((match = macro.exec(str))) {
          // match[1] = macro-letter
    Severity: Minor
    Found in lib/spf.js - About 5 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 check_host has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async check_host(ip, domain, mail_from) {
        domain = domain.toLowerCase()
        mail_from = mail_from ? mail_from.toLowerCase() : `postmaster@${domain}`
        this.ipaddr = ipaddr.parse(ip)
        this.ip_ver = this.ipaddr.kind()
    Severity: Major
    Found in lib/spf.js - About 4 hrs to fix

      Function hook_mail has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.hook_mail = async function (next, connection, params) {
        const plugin = this
      
        const txn = connection?.transaction
        if (!txn) return next()
      Severity: Minor
      Found in index.js - About 4 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 hook_mail has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.hook_mail = async function (next, connection, params) {
        const plugin = this
      
        const txn = connection?.transaction
        if (!txn) return next()
      Severity: Major
      Found in index.js - About 4 hrs to fix

        Function mech_mx has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async mech_mx(qualifier, args) {
            this.count++
            // Parse any arguments
            let cm
            let cidr4
        Severity: Major
        Found in lib/spf.js - About 3 hrs to fix

          Function return_results has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.return_results = function (
            next,
            connection,
            spf,
            scope,
          Severity: Minor
          Found in index.js - About 3 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

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

          // spf
          
          const SPF = require('./lib/spf').SPF
          const net_utils = require('haraka-net-utils')
          const DSN = require('haraka-dsn')
          Severity: Minor
          Found in index.js - About 3 hrs to fix

            Function mech_a has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              async mech_a(qualifier, args) {
                this.count++
                // Parse any arguments
                let cm
                let cidr4
            Severity: Minor
            Found in lib/spf.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 mech_ptr has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

              async mech_ptr(qualifier, args) {
                this.count++
                let dm
                let domain = this.domain
                if (args && (dm = /^:([^/ ]+)/.exec(args))) {
            Severity: Minor
            Found in lib/spf.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 mech_a has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async mech_a(qualifier, args) {
                this.count++
                // Parse any arguments
                let cm
                let cidr4
            Severity: Major
            Found in lib/spf.js - About 2 hrs to fix

              Function load_spf_ini has 54 lines of code (exceeds 25 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: Major
              Found in index.js - About 2 hrs to fix

                Function expand_macros has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  expand_macros(str) {
                    const macro = /%{([slodipvh])((?:(?:\d+)?r?)?)?([-.+,/_=])?}/gi
                    let match
                    while ((match = macro.exec(str))) {
                      // match[1] = macro-letter
                Severity: Major
                Found in lib/spf.js - About 2 hrs to fix

                  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

                          Severity
                          Category
                          Status
                          Source
                          Language