File smtp_forward.js
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// Forward to an SMTP server
// Opens the connection to the ongoing SMTP server at queue time
// and passes back any errors seen on the ongoing server to the
// originating server.
Function queue_forward
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.queue_forward = function (next, connection) {
const plugin = this;
const txn = connection?.transaction;
const cfg = plugin.get_config(connection);
Function set_queue
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.set_queue = function (connection, queue_wanted, domain) {
let dom_cfg = this.cfg[domain];
if (dom_cfg === undefined) dom_cfg = {};
- 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 auth
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.auth = function (cfg, connection, smtp_client) {
connection.loginfo(this, `Configuring authentication for SMTP server ${cfg.host}:${cfg.port}`);
smtp_client.on('capabilities', () => {
connection.loginfo(this, 'capabilities received');
Function auth
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports.auth = function (cfg, connection, smtp_client) {
connection.loginfo(this, `Configuring authentication for SMTP server ${cfg.host}:${cfg.port}`);
smtp_client.on('capabilities', () => {
connection.loginfo(this, 'capabilities received');
- 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 get_config
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports.get_config = function (conn) {
if (!conn.transaction) return this.cfg.main;
let dom;
- 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 check_recipient
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.check_recipient = function (next, connection, params) {
const txn = connection?.transaction;
if (!txn) return;
const rcpt = params[0];
- 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
if (next_hop === dst_host) return true;
Avoid too many return
statements within this function. Open
return next(DENYSOFT, "Split transaction, retry soon");
Avoid too many return
statements within this function. Open
return this.cfg[dom];
Avoid too many return
statements within this function. Open
if (!this.cfg[dom]) return this.cfg.main; // no specific route
Avoid too many return
statements within this function. Open
if (!next_hop) return true;
Avoid too many return
statements within this function. Open
return false;
Function get_mx
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.get_mx = function (next, hmail, domain) {
const qw = hmail.todo.notes.get('queue.wants')
if (qw && qw !== 'smtp_forward') return next()
- 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"