Showing 655 of 655 total issues
File index.js
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const fs = require('fs');
const path = require('path');
Function setupClient
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
static setupClient (self) {
const ip = self.client.remoteAddress;
if (!ip) {
self.logdebug('setupClient got no IP address for this connection!');
self.client.destroy();
Consider simplifying this complex logical expression. Open
if (config.rabbitmq) {
options.host = config.rabbitmq.server_ip || '127.0.0.1';
options.port = config.rabbitmq.server_port || '5672';
options.login = config.rabbitmq.user || 'guest';
options.password = config.rabbitmq.password || 'guest';
Function bounce_spf
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.bounce_spf = function (next, connection) {
if (!this.cfg.check.bounce_spf) return next();
if (!this.has_null_sender(connection)) return next();
const txn = connection?.transaction;
Function hook_deny
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_deny = function (next, connection, params) {
/* params
** [0] = plugin return value (DENY or DENYSOFT)
** [1] = plugin return message
*/
File logger.js
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// Log class
const util = require('util');
const tty = require('tty');
Function add_dot_stuffing_and_ensure_crlf_newlines
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
add_dot_stuffing_and_ensure_crlf_newlines (data) {
if (!data.length) return data;
if (!Buffer.isBuffer(data)) data = Buffer.from(data);
// Make a new buffer big enough to hold two bytes for every one input
- 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 write
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
write (buf) {
/*
** BODY (simple canonicalization)
*/
- 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 end_data
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
end_data (cb) {
if (!this.found_hb_sep && this.header_lines.length) {
// Headers not parsed yet - must be a busted email
// Strategy: Find the first line that doesn't look like a header.
// Treat anything before that as headers, anything after as body.
- 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 add_data
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
add_data (line) {
if (typeof line === 'string') { // This shouldn't ever happen.
line = Buffer.from(line, this.encoding);
}
// is this the end of headers line?
- 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
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 hook_rcpt_ok
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_rcpt_ok = function (next, connection, rcpt) {
if (this.should_skip_check(connection)) return next();
if (this.was_whitelisted_in_session(connection)) {
this.logdebug(connection, 'host already whitelisted in this session');
Function get_certs_dir
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_certs_dir = (tlsDir, done) => {
this.config.getDir(tlsDir, {}, (iterErr, files) => {
if (iterErr) return done(iterErr);
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
re = new RegExp(element.substr(1, element.length-2),'i');
new_skip_list.push(re);
}
catch (e) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
else if (rcpt_to.dsn_code) {
if (/^5/.exec(rcpt_to.dsn_code)) {
dsn_action = 'failed';
}
else if (/^4/.exec(rcpt_to.dsn_code)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
re = new RegExp(element.substr(2, element.length-2),'i');
new_skip_list_exclude.push(re);
}
catch (e) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
else if (rcpt_to.dsn_smtp_code) {
if (/^5/.exec(rcpt_to.dsn_smtp_code)) {
dsn_action = 'failed';
}
else if (/^4/.exec(rcpt_to.dsn_smtp_code)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function hook_data_post
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.hook_data_post = function (next, connection) {
const plugin = this;
const cfg = this.config.get('esets.ini');
// Write message to temporary file
- 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_user
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.check_user = function (next, connection, credentials, method) {
const plugin = this;
connection.notes.authenticating = false;
if (!(credentials[0] && credentials[1])) {
connection.respond(504, 'Invalid AUTH string', () => {
- 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"