msimerson/Haraka

View on GitHub
outbound/index.js

Summary

Maintainability
D
1 day
Test Coverage

Function send_email has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

exports.send_email = function () {

    if (arguments.length === 2) {
        logger.logdebug("[outbound] Sending email as a transaction");
        return this.send_trans_email(arguments[0], arguments[1]);
Severity: Minor
Found in outbound/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 send_email has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.send_email = function () {

    if (arguments.length === 2) {
        logger.logdebug("[outbound] Sending email as a transaction");
        return this.send_trans_email(arguments[0], arguments[1]);
Severity: Major
Found in outbound/index.js - About 3 hrs to fix

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

    'use strict';
    
    const fs          = require('fs');
    const path        = require('path');
    
    
    Severity: Minor
    Found in outbound/index.js - About 2 hrs to fix

      Function send_trans_email has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.send_trans_email = function (transaction, next) {
      
          // add potentially missing headers
          if (!transaction.header.get_all('Message-Id').length) {
              logger.loginfo("[outbound] Adding missing Message-Id header");
      Severity: Minor
      Found in outbound/index.js - About 1 hr to fix

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

        exports.process_delivery = function (ok_paths, todo, hmails, cb) {
            logger.loginfo(`[outbound] Transaction delivery for domain: ${todo.domain}`);
            const fname = _qfile.name();
            const tmp_path = path.join(queue_dir, `${_qfile.platformDOT}${fname}`);
            const ws = new FsyncWriteStream(tmp_path, { flags: constants.WRITE_EXCL });
        Severity: Minor
        Found in outbound/index.js - About 1 hr to fix

          Function pre_send_trans_email_respond has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              connection.pre_send_trans_email_respond = retval => {
                  const deliveries = get_deliveries(transaction);
                  const hmails = [];
                  const ok_paths = [];
          
          
          Severity: Minor
          Found in outbound/index.js - About 1 hr to fix

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

            function stream_line_reader (stream, transaction, cb) {
                let current_data = '';
                function process_data (data) {
                    current_data += data.toString();
                    let results;
            Severity: Minor
            Found in outbound/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 stream_line_reader(contents, transaction, err => {
                        if (err) {
                            return next(constants.denysoft, `Error from stream line reader: ${err}`);
                        }
                        exports.send_trans_email(transaction, next);
            Severity: Major
            Found in outbound/index.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status