Showing 105 of 189 total issues
Function mapBuilderForKeyType
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mapBuilderForKeyType(keyType) {
return function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
Function createSender
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
AMQPClient.prototype.createSender = function(address, policyOverrides, session) {
if (!this._connection) {
throw new Error('Must connect before creating links');
}
Function parseAddress
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Policy.prototype.parseAddress = function(address) {
var parsedAddress = url.parse(address);
var result = {
host: parsedAddress.hostname || parsedAddress.href,
path: (parsedAddress.path && parsedAddress.path !== address) ?
- 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 encoder
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
encoder: function(val, bufb) {
if (val instanceof Int64) return bufb.appendBuffer(val.toBuffer(true));
if (val instanceof Buffer) return bufb.appendBuffer(val);
if (typeof val !== 'number' || !(val instanceof Number)) val = Number(val);
if (!Number.isFinite(val)) {
- 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 encoder
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
encoder: function(val, bufb) {
var code = 0x80;
if (val instanceof Int64 || val > 0xFF) {
var check = (val instanceof Int64) ? val.toNumber(true) : val;
if (check === 0) {
- 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 encodeMessage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.encodeMessage = function(message, buffer) {
var _keys = Object.keys(sectionByProperty), _len = _keys.length;
for (var i = 0; i < _len; ++i) {
var property = _keys[i], definition = sectionByProperty[property];
if (message.hasOwnProperty(property)) {
Function mapBuilder
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
Function _messageReceived
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
ReceiverLink.prototype._messageReceived = function(transferFrame) {
if (transferFrame.aborted) {
this._currentTransferFrame = null;
debug('Message transfer aborted.');
return;
Function mapBuilder
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
Function writeFrame
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
frames.writeFrame = function(frame, stream, options, callback) {
if (!(frame instanceof frames.Frame)) {
throw new errors.EncodingError(frame, 'unknown frame type');
}
Function _encodeObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Codec.prototype._encodeObject = function(value, buffer) {
if (value instanceof DescribedType) {
buffer.appendUInt8(0x00);
// NOTE: Described type constructors are either ulongs or a symbol. Here
Function parseAddress
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Policy.prototype.parseAddress = function(address) {
var parsedAddress = url.parse(address);
var result = {
host: parsedAddress.hostname || parsedAddress.href,
path: (parsedAddress.path && parsedAddress.path !== address) ?
Function wrapField
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wrapField(field, value) {
if (value instanceof ForcedType) return value;
if (value === undefined || value === null) {
if (field.mandatory) throw new Error('missing mandatory field: ' + field.name);
if (field.hasOwnProperty('default')) return wrapField(field, field.default);
Function _processFrame
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Session.prototype._processFrame = function(frame) {
if (frame instanceof frames.BeginFrame && (frame.remoteChannel === this.channel)) {
this.sm.beginReceived();
this._beginReceived(frame);
return;
- 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 Connection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function Connection(connectPolicy) {
Connection.super_.call(this);
var options = connectPolicy.options;
u.assertArguments(options, ['containerId', 'hostname']);
- 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 _tryReceiveHeader
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Connection.prototype._tryReceiveHeader = function(header) {
header = header || constants.amqpVersion;
if (this._buffer.length >= header.length) {
var serverVersion = this._buffer.slice(0, 8);
this._buffer.consume(8);
Function stateMachine
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var stateMachine = function(link) {
var detachHandler = function(frame) {
if (this.getMachineState() === 'ATTACHED') {
this.ATTACHED.sendDetach({ closed: frame.closed });
}
Function parseHex
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseHex(hexstr) {
var amqpstr = constants.amqpVersion.toString('hex');
var headerIdx = hexstr.indexOf(amqpstr);
var body = hexstr;
if (headerIdx === -1) {
Function createLink
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Session.prototype.createLink = function(linkPolicy) {
var policy = u.deepCopy(linkPolicy),
attachOptions = policy.attach || {};
attachOptions.handle = this._nextHandle();
Function _getSession
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
AMQPClient.prototype._getSession = function(session) {
// Just return the provided session if one was passed in
if (session) {
return Promise.resolve(session);
}