plugins/messagesniffer.js
Function hook_data_post
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.hook_data_post = function (next, connection) {
const cfg = this.config.get('messagesniffer.ini');
const txn = connection?.transaction;
if (!txn) return next();
File messagesniffer.js
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// messagesniffer
const fs = require('fs');
const net = require('net');
const plugin = exports;
Function hook_connect
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.hook_connect = function (next, connection) {
const cfg = this.config.get('messagesniffer.ini');
// Skip any private IP ranges
// Skip connection.transaction undefined
if (connection?.remote?.is_private || !connection?.transaction) return next();
Avoid deeply nested control flow statements. Open
Open
else if (code === 20) {
if (cfg.message.truncate) {
action = cfg.message.truncate;
}
else {
Avoid deeply nested control flow statements. Open
Open
switch (precedence) {
case 'bulk':
case 'list':
case 'junk':
// Leave these as they are
Avoid deeply nested control flow statements. Open
Open
if (cfg.message.local_white) {
action = cfg.message.local_white;
}
else {
return next(OK);
Avoid deeply nested control flow statements. Open
Open
if (headers[headers.length-1]) {
headers[headers.length-1].value += `${line}\r\n`;
}
Avoid deeply nested control flow statements. Open
Open
if (match) {
headers.push({ header: match[1], value: (match[2] ? `${match[2]}\r\n` : '\r\n') });
}
Function hook_data_post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
exports.hook_data_post = function (next, connection) {
const cfg = this.config.get('messagesniffer.ini');
const txn = connection?.transaction;
if (!txn) 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"
Further reading
Avoid too many return
statements within this function. Open
Open
return next();
Avoid too many return
statements within this function. Open
Open
return next();
Avoid too many return
statements within this function. Open
Open
return next(DENY, `Poor GBUdb reputation for [${connection.remote.ip}]`);
Avoid too many return
statements within this function. Open
Open
return next();
Avoid too many return
statements within this function. Open
Open
return next();