Showing 655 of 655 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (this.cfg.check.private_ip == false && connection.remote.is_private) {
if (this.cfg.check.local_ip == true && connection.remote.is_local) {
// local IPs are included in private IPs
}
else {
- 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 109.
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
if (this.cfg.check.private_ip == false && connection.remote.is_private) {
if (this.cfg.check.local_ip == true && connection.remote.is_local) {
// local IPs are included in private IPs
}
else {
- 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 109.
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 _process_data
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
_process_data () {
// We *must* detect disconnected connections here as the state
// only transitions to states.CMD in the respond function below.
// Otherwise if multiple commands are pipelined and then the
// connection is dropped; we'll end up in the function forever.
File messagesniffer.js
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
// messagesniffer
const fs = require('fs');
const net = require('net');
const plugin = exports;
HMailItem
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class HMailItem extends events.EventEmitter {
constructor (filename, filePath, notes) {
super();
const parts = _qfile.parts(filename);
File spamassassin.js
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// Call spamassassin via spamd
const sock = require('./line_socket');
const utils = require('haraka-utils');
Function hook_mail
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_mail = function (next, connection, params) {
const plugin = this;
const mail_from = params[0];
const txn = connection?.transaction;
if (!txn) return next();
Function constructor
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (client, server, cfg) {
this.client = client;
this.server = server;
this.cfg = cfg;
Function hook_deny
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
exports.hook_deny = function (next, connection, params) {
/* params
** [0] = plugin return value (DENY or DENYSOFT)
** [1] = plugin return message
*/
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
const asArray = cfg.cert.map(certFileName => {
if (!certFileName) return;
const cert = this.config.get(certFileName, 'binary');
if (!cert) {
log.logerror(`tls cert ${path.join(this.config.root_path, certFileName)} could not be loaded.`);
- 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 100.
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
const asArray = cfg.key.map(keyFileName => {
if (!keyFileName) return;
const key = this.config.get(keyFileName, 'binary');
if (!key) {
log.logerror(`tls key ${path.join(this.config.root_path, keyFileName)} could not be loaded.`);
- 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 100.
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 end
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
end () {
if (this.run_cb) return;
const bh = this.bh.digest('base64');
this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`);
- 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 clamd.js
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
// clamd
const sock = require('./line_socket');
const utils = require('haraka-utils');
Function run_next_hook
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
plugins.run_next_hook = (hook, object, params) => {
if (client_disconnected(object) && !is_required_hook(hook)) {
object.logdebug(`aborting ${hook} hook`);
return;
}
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]);
Function load_excludes
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
exports.load_excludes = function () {
this.loginfo('Loading excludes file');
const list = this.config.get('clamd.excludes','list', () => {
this.load_excludes();
- 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 set_temp_fail_intervals
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
exports.set_temp_fail_intervals = function () {
// Set the outbound temp fail intervals (retry times) using the following rules:
// 1) temp_fail_intervals takes precedence over maxTempFailures if both are specified
// 2) if temp_fail_intervals is not specified or is illegally specified, then initialize
// it with the equivalent times of maxTempFailures using the original 2^N formula
- 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 onCapabilitiesOutbound
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
exports.onCapabilitiesOutbound = (smtp_client, secured, connection, config, on_secured) => {
for (const line in smtp_client.response) {
if (/^XCLIENT/.test(smtp_client.response[line])) {
if (!smtp_client.xclient) {
smtp_client.send_command('XCLIENT', `ADDR=${connection.remote.ip}`);
- 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 hook_data_post
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_data_post = function (next, connection) {
if (this.should_skip(connection)) return next();
const txn = connection.transaction;
Similar blocks of code found in 3 locations. Consider refactoring. Open
recipients.forEach(rcpt => {
rcpt.dsn_action = 'failed';
rcpt.dsn_smtp_code = code;
rcpt.dsn_smtp_extc = extc;
rcpt.dsn_status = extc;
- 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 95.
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