Showing 31 of 37 total issues
Function connect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
TcpConnection.prototype.connect = function (callback) {
var self = this;
if (logger.isDebugEnabled()) {
logger.debug('Connecting to %s', self._config);
}
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
TcpConnection.prototype.write = function (data, callback) {
var self = this;
var socket = this._socket;
if (!socket && callback) {
callback(createError('Not yet connected', 'ENOTCONNECTED'));
- 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 read
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
TcpConnection.prototype.read = function (callback) {
var self = this;
var buffers = [];
var timer;
if (logger.isDebugEnabled()) {
- 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 deserialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
EncryptedMessage.prototype.deserialize = function (isSymmetric) {
if (!this.isReadonly() || !this.authKey) {
var msg = 'Unable to deserialize the message, "message" is not readonly || "authKey" is undefined!';
logger.warn(msg);
throw new Error(msg);
Function decryptDHParams
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function decryptDHParams(context) {
var newNonce = utility.string2Buffer(context.newNonce, 32);
var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
if (logger.isDebugEnabled()) {
logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'));
Function EncryptedMessage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function EncryptedMessage(options) {
var opts = options ? options : {};
this.constructor.super_.call(this, opts.buffer, opts.offset);
this.authKey = opts.authKey;
if (opts.message) {
Function findPublicKey
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function findPublicKey(context) {
var fingerprints = context.resPQ.server_public_key_fingerprints.getList();
if (logger.isDebugEnabled()) {
logger.debug('Public keys fingerprints from server: %s', fingerprints);
}
- 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 createSHAHash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function createSHAHash(buffer, algorithm) {
var logger = getLogger('utility.createSHA1Hash');
var sha1sum = crypto.createHash(algorithm || 'sha1');
if (require('util').isArray(buffer)) {
if (logger.isDebugEnabled()) {
- 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 deeply nested control flow statements. Open
if (b.repr[0] & 1) {
c.addEquals(a);
if (c.gt(num)) {
c = c.subtract(num);
}
Avoid deeply nested control flow statements. Open
if (a.gt(num)) {
a = a.subtract(num);
}
Function timeSynchronization
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function timeSynchronization(serverTime, requestDuration) {
var logger = getLogger('time.timeSynchronization');
var localTime = Math.floor(new Date().getTime() / 1000);
var response = requestDuration / 2;
if (logger.isDebugEnabled()) {
- 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"