Showing 655 of 655 total issues
File connection.js
has 1689 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// a single connection
// node.js built-in libs
const dns = require('dns');
File hmail.js
has 1246 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const events = require('events');
const fs = require('fs');
const dns = require('dns');
Function try_deliver_host_on_socket
has 467 lines of code (exceeds 25 allowed). Consider refactoring. Open
try_deliver_host_on_socket (mx, host, port, socket) {
const self = this;
let processing_mail = true;
let command = mx.using_lmtp ? 'connect_lmtp' : 'connect';
Function try_deliver_host_on_socket
has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring. Open
try_deliver_host_on_socket (mx, host, port, socket) {
const self = this;
let processing_mail = true;
let command = mx.using_lmtp ? 'connect_lmtp' : 'connect';
- 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 handle_buf
has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring. Open
handle_buf (buf) {
const self = this;
// Abort any further processing if the headers
// did not contain any DKIM-Signature fields.
if (this._in_body && this._no_signatures_found) {
- 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 tls_socket.js
has 583 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
/*--------------------------------------------------------------------------*/
/* Obtained and modified from http://js.5sh.net/starttls.js on 8/18/2011. */
/*--------------------------------------------------------------------------*/
Connection
has 64 functions (exceeds 20 allowed). Consider refactoring. Open
class Connection {
constructor (client, server, cfg) {
this.client = client;
this.server = server;
this.cfg = cfg;
File server.js
has 540 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// smtp network server
const daemon = require('daemon');
const fs = require('fs');
File dkim.js
has 511 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const crypto = require('crypto');
const dns = require('dns');
const { Stream } = require('stream');
Function populate_bounce_message_with_headers
has 201 lines of code (exceeds 25 allowed). Consider refactoring. Open
populate_bounce_message_with_headers (from, to, reason, header, cb) {
const CRLF = '\r\n';
const originalMessageId = header.get('Message-Id');
Function constructor
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
constructor (header, header_idx, cb, opts) {
this.cb = cb;
this.sig = header;
this.sig_md5 = md5(header);
this.run_cb = false;
- 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 plugins.js
has 488 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// load all defined plugins
// node built-ins
const fs = require('fs');
Function hook_data_post
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_data_post = function (next, connection) {
const cfg = this.config.get('messagesniffer.ini');
const txn = connection?.transaction;
if (!txn) return next();
Function log_if_level
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
logger.log_if_level = (level, key, plugin) => function () {
if (logger.loglevel < logger[key]) { return; }
let logobj = {
level,
uuid: '-',
- 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 greylist.js
has 457 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Greylisting plugin for Haraka
// version 0.1.4
// node builtins
Function _process_data
has a Cognitive Complexity of 45 (exceeds 5 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.
- 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_unrecognized_command
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
exports.hook_unrecognized_command = function (next, connection, params) {
if (params[0] !== 'XCLIENT') return next();
// XCLIENT is not allowed after transaction start
if (connection?.transaction) {
- 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
try {
results = rfc1869.parse('mail', line, this.cfg.main.strict_rfc1869 && !this.relaying);
}
catch (err) {
this.errors++;
- 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 165.
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 {
results = rfc1869.parse('rcpt', line, this.cfg.main.strict_rfc1869 && !this.relaying);
}
catch (err) {
this.errors++;
- 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 165.
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 try_auth_proxy
has 153 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
if (!hosts || (hosts && !hosts.length)) return cb(false);
if (typeof hosts !== 'object') {
hosts = [ hosts ];
}