outbound/index.js
Function send_email
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
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]);
- Read upRead up
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
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]);
File index.js
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
const fs = require('fs');
const path = require('path');
Function send_trans_email
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
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");
Function process_delivery
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 });
Function pre_send_trans_email_respond
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
connection.pre_send_trans_email_respond = retval => {
const deliveries = get_deliveries(transaction);
const hmails = [];
const ok_paths = [];
Function stream_line_reader
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function stream_line_reader (stream, transaction, cb) {
let current_data = '';
function process_data (data) {
current_data += data.toString();
let results;
- Read upRead up
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
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);