Showing 12 of 35 total issues
File diameter-codec.js
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
var _ = require('lodash');
var diameterTypes = require('./diameter-types');
var diameterUtil = require('./diameter-util');
Function encodeAvp
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
var encodeAvp = function(avp, appId) {
var avpTag;
if (!_.isNumber(avp[0])) {
avpTag = dictionary.getAvpByName(avp[0]);
} else {
- 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 DiameterConnection
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
function DiameterConnection(options, socket) {
if (!(this instanceof DiameterConnection)) {
return new DiameterConnection(options, socket);
}
options = options || {};
Function server
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
var server = diameter.createServer(options, function(socket) {
socket.on('diameterMessage', function(event) {
if (event.message.command === 'Capabilities-Exchange') {
event.response.body = event.response.body.concat([
['Result-Code', 'DIAMETER_SUCCESS'],
Function encodeAvp
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
var encodeAvp = function(avp, appId) {
var avpTag;
if (!_.isNumber(avp[0])) {
avpTag = dictionary.getAvpByName(avp[0]);
} else {
Function decodeAvp
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
var decodeAvp = function(buffer, start, appId) {
var avp = decodeAvpHeader(buffer, start);
var hasVendorId = avp.flags.vendor;
if (hasVendorId) {
- 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 decodeAvp
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var decodeAvp = function(buffer, start, appId) {
var avp = decodeAvpHeader(buffer, start);
var hasVendorId = avp.flags.vendor;
if (hasVendorId) {
Function constructRequest
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.constructRequest = function(applicationName, commandName, sessionId) {
var application = findApplication(applicationName);
if (application == undefined) {
throw new Error('Application ' + applicationName + ' not found in dictionary. ');
}
Function getAvpValue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.getAvpValue = function(message, path) {
var pathElements = getPathElements(path);
if (pathElements.length === 0) return undefined;
var firstAvpName = pathElements[0].name;
var avps = _.filter(message, function(avp) {
- 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 DiameterConnection
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function DiameterConnection(options, socket) {
if (!(this instanceof DiameterConnection)) {
return new DiameterConnection(options, socket);
}
options = options || {};
- 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 (_.isFunction(self.options.afterAnyMessage)) {
self.options.afterAnyMessage(message);
}
Function decode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
decode: function(buffer) {
var octetsArray = [];
for (var i = 0; i < buffer.length; i++) {
octetsArray.push(buffer.readUInt8(i));
}
- 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"