node-diameter/node-diameter

View on GitHub

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');
Severity: Minor
Found in lib/diameter-codec.js - About 3 hrs to fix

    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 {
    Severity: Minor
    Found in lib/diameter-codec.js - About 3 hrs to fix

    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 || {};
    Severity: Major
    Found in lib/diameter-connection.js - About 3 hrs to fix

      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'],
      Severity: Major
      Found in examples/diameter-server-example.js - About 3 hrs to fix

        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 {
        Severity: Major
        Found in lib/diameter-codec.js - About 2 hrs to fix

          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) {
          Severity: Minor
          Found in lib/diameter-codec.js - About 2 hrs to fix

          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) {
          Severity: Minor
          Found in lib/diameter-codec.js - About 1 hr to fix

            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. ');
                }
            Severity: Minor
            Found in lib/diameter-codec.js - About 1 hr to fix

              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) {
              Severity: Minor
              Found in lib/diameter-util.js - About 1 hr to fix

              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 || {};
              Severity: Minor
              Found in lib/diameter-connection.js - About 55 mins to fix

              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);
                                          }
              Severity: Major
              Found in lib/diameter-connection.js - About 45 mins to fix

                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));
                            }
                Severity: Minor
                Found in lib/diameter-types.js - About 25 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language