Function _encodeObject
has a Cognitive Complexity of 20 (exceeds 5 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
- 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 _readFullValue
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Codec.prototype._readFullValue = function(buf, offset, doNotConsume, forcedCode) {
offset = offset || 0;
var remaining = buf.length - offset;
if (remaining < 1) return undefined;
- 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 _readFullValue
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Codec.prototype._readFullValue = function(buf, offset, doNotConsume, forcedCode) {
offset = offset || 0;
var remaining = buf.length - offset;
if (remaining < 1) return undefined;
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 encode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Codec.prototype.encode = function(value, buffer, forceType) {
// Special-case null values
if (value === null) {
return types.null.encode(value, buffer);
}
- 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 _readOrPeekFixed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Codec.prototype._readOrPeekFixed = function(buf, offset, remaining, doNotConsume, numBytes) {
Avoid too many return
statements within this function. Open
if (value instanceof Array) return types.list.encode(value, buffer, this);
Avoid too many return
statements within this function. Open
if (value instanceof ForcedType) return this.encode(value.value, buffer, value.typeName);
Avoid too many return
statements within this function. Open
if (remaining < 5) return false;
Avoid too many return
statements within this function. Open
return this._readOrPeekFixed(buf, offset, remaining, doNotConsume, numBytes);
Avoid too many return
statements within this function. Open
return this._readOrPeekFixed(buf, offset, remaining, doNotConsume, numBytes);
Avoid too many return
statements within this function. Open
return encoder(value, buffer, this);
Avoid too many return
statements within this function. Open
return types.long.encode(value, buffer);
Avoid too many return
statements within this function. Open
return types.map.encode(value, buffer, this);
Avoid too many return
statements within this function. Open
if (value instanceof Date) return types.timestamp.encode(new Int64(value.getTime()), buffer, this);
Avoid too many return
statements within this function. Open
return value.encode(this, buffer);
Function _asMostSpecific
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Codec.prototype._asMostSpecific = function(buf, forcedCode) {
if (buf instanceof Array) {
// Described type
var descriptor = this._asMostSpecific(buf[0]);
var value = this._asMostSpecific(buf[1]);
- 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 _encodeNumber
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Codec.prototype._encodeNumber = function(value, buffer) {
if (isNaN(value) || !isFinite(value)) {
throw new errors.EncodingError(value, 'value is not a finite number');
}
- 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"