node-diameter/node-diameter

View on GitHub

Showing 35 of 35 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

var testGetApplicationByName = function() {
    var names = [];
    for (var j = 0; j < 8; j++) {
        names.push(dictionary.getApplicationById(j).name);
    }
Severity: Major
Found in load_test/diameter-dictionary.js and 2 other locations - About 5 hrs to fix
load_test/diameter-dictionary.js on lines 19..31
load_test/diameter-dictionary.js on lines 67..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

var testGetAvpByName = function() {
    var names = [];
    for (var j = 0; j < 10; j++) {
        names.push(dictionary.getAvpByCode(j).name);
    }
Severity: Major
Found in load_test/diameter-dictionary.js and 2 other locations - About 5 hrs to fix
load_test/diameter-dictionary.js on lines 43..55
load_test/diameter-dictionary.js on lines 67..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

var testGetCommandByName = function() {
    var names = [];
    for (var j = 100; j < 104; j++) {
        names.push(dictionary.getCommandByCode(j).name);
    }
Severity: Major
Found in load_test/diameter-dictionary.js and 2 other locations - About 5 hrs to fix
load_test/diameter-dictionary.js on lines 19..31
load_test/diameter-dictionary.js on lines 43..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    'Unsigned64': {
        encode: function(value) {
            var buffer = new Buffer(8);
            if (value instanceof Long) {
                buffer.writeUInt32BE(value.getHighBitsUnsigned(), 0);
Severity: Major
Found in lib/diameter-types.js and 1 other location - About 5 hrs to fix
lib/diameter-types.js on lines 61..76

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    'Integer64': {
        encode: function(value) {
            var buffer = new Buffer(8);
            if (value instanceof Long) {
                buffer.writeInt32BE(value.getHighBits(), 0);
Severity: Major
Found in lib/diameter-types.js and 1 other location - About 5 hrs to fix
lib/diameter-types.js on lines 45..60

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      var testGetApplicationById = function() {
          var startTime = process.hrtime();
          for (var i = 0; i < ITERATIONS; i++) {
              for (var j = 0; j < 8; j++) {
                  dictionary.getApplicationById(j);
      Severity: Major
      Found in load_test/diameter-dictionary.js and 2 other locations - About 3 hrs to fix
      load_test/diameter-dictionary.js on lines 9..17
      load_test/diameter-dictionary.js on lines 57..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      var testGetCommandByCode = function() {
          var startTime = process.hrtime();
          for (var i = 0; i < ITERATIONS; i++) {
              for (var j = 100; j < 104; j++) {
                  dictionary.getCommandByCode(j);
      Severity: Major
      Found in load_test/diameter-dictionary.js and 2 other locations - About 3 hrs to fix
      load_test/diameter-dictionary.js on lines 9..17
      load_test/diameter-dictionary.js on lines 33..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      var testGetAvpByCode = function() {
          var startTime = process.hrtime();
          for (var i = 0; i < ITERATIONS; i++) {
              for (var j = 0; j < 10; j++) {
                  dictionary.getAvpByCode(j);
      Severity: Major
      Found in load_test/diameter-dictionary.js and 2 other locations - About 3 hrs to fix
      load_test/diameter-dictionary.js on lines 33..41
      load_test/diameter-dictionary.js on lines 57..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getAvpByCode = function(code) {
            var cached = cache.avpsByCode[code];
            if (cached !== undefined) return cached;
            var avp = _.find(dictionary.avps, {code: code});
            cache.avpsByCode[code] = avp;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 17..23
        lib/diameter-dictionary.js on lines 25..31
        lib/diameter-dictionary.js on lines 33..39
        lib/diameter-dictionary.js on lines 41..47
        lib/diameter-dictionary.js on lines 67..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getApplicationById = function(appId) {
            var cached = cache.applicationsById[appId];
            if (cached !== undefined) return cached;
            var app = _.find(dictionary.applications, {code: appId});
            cache.applicationsById[appId] = app;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 25..31
        lib/diameter-dictionary.js on lines 33..39
        lib/diameter-dictionary.js on lines 41..47
        lib/diameter-dictionary.js on lines 49..55
        lib/diameter-dictionary.js on lines 67..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getApplicationByName = function(name) {
            var cached = cache.applicationsByName[name];
            if (cached !== undefined) return cached;
            var app = _.find(dictionary.applications, {name: name});
            cache.applicationsByName[name] = app;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 17..23
        lib/diameter-dictionary.js on lines 33..39
        lib/diameter-dictionary.js on lines 41..47
        lib/diameter-dictionary.js on lines 49..55
        lib/diameter-dictionary.js on lines 67..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getCommandByName = function(name) {
            var cached = cache.commandsByName[name];
            if (cached !== undefined) return cached;
            var command = _.find(dictionary.commands, {name: name});
            cache.commandsByName[name] = command;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 17..23
        lib/diameter-dictionary.js on lines 25..31
        lib/diameter-dictionary.js on lines 33..39
        lib/diameter-dictionary.js on lines 49..55
        lib/diameter-dictionary.js on lines 67..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getCommandByCode = function(code) {
            var cached = cache.commandsByCode[code];
            if (cached !== undefined) return cached;
            var command = _.find(dictionary.commands, {code: code});
            cache.commandsByCode[code] = command;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 17..23
        lib/diameter-dictionary.js on lines 25..31
        lib/diameter-dictionary.js on lines 41..47
        lib/diameter-dictionary.js on lines 49..55
        lib/diameter-dictionary.js on lines 67..73

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        exports.getAvpByName = function(name) {
            var cached = cache.avpsByName[name];
            if (cached !== undefined) return cached;
            var avp = _.find(dictionary.avps, {name: name});
            cache.avpsByName[name] = avp;
        Severity: Major
        Found in lib/diameter-dictionary.js and 5 other locations - About 2 hrs to fix
        lib/diameter-dictionary.js on lines 17..23
        lib/diameter-dictionary.js on lines 25..31
        lib/diameter-dictionary.js on lines 33..39
        lib/diameter-dictionary.js on lines 41..47
        lib/diameter-dictionary.js on lines 49..55

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 87.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Severity
          Category
          Status
          Source
          Language