msimerson/postfix-parser

View on GitHub

Showing 10 of 12 total issues

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


const logger = require('./lib/logger')

const envEmailAddr   = '<?([^>,]*)>?'
const postfixQid     = '[0-9A-F]{10,11}'     // default queue ids
Severity: Minor
Found in index.js - About 2 hrs to fix

    Function smtpAsObject has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function smtpAsObject (line) {
      let match = line.match(regex.smtp)
      if (match) return matchAsObject(match)
    
      match = line.match(regex['smtp-conn-err'])
    Severity: Minor
    Found in index.js - About 1 hr to fix

      Function asObjectType has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.asObjectType = function (type, line) {
        if (!type || !line) {
          logger.error('missing required arg')
          return
        }
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function smtpAsObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function smtpAsObject (line) {
          let match = line.match(regex.smtp)
          if (match) return matchAsObject(match)
        
          match = line.match(regex['smtp-conn-err'])
        Severity: Minor
        Found in index.js - About 45 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

        Avoid too many return statements within this function.
        Open

            return {
              action: 'defer',
              qid   : match[1],
              host  : match[2],
              msg   : match[3],
        Severity: Major
        Found in index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return {
                qid: match[1],
                msg: match[2],
              }
          Severity: Major
          Found in index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

                return { msg: match[0] }
              Severity: Major
              Found in index.js - About 30 mins to fix

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

                exports.asObjectType = function (type, line) {
                  if (!type || !line) {
                    logger.error('missing required arg')
                    return
                  }
                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 matchAsObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function matchAsObject (match) {
                  match.shift()
                  const obj = {}
                  const qid = match.shift()
                  if (qid) obj.qid = qid
                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