Showing 258 of 258 total issues

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

        function lookup(obj, type, lookupValue) {
          var result = [];
          traverse(obj).map(function (x) {

            if (kindof(x) === 'object') {
Severity: Major
Found in lib/dispatch/collections.js and 1 other location - About 4 hrs to fix
lib/dispatch/collections.js on lines 153..165

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 119.

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 middleware has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

auth.middleware = function (req, res, next) {
  var debug = {};
  var parts = url.parse(req.url);

  //TODO: Add header to SDK
Severity: Major
Found in lib/common/auth.js - About 4 hrs to fix

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

    auth.hashPassword = function (plainPassword, salt) {
      if (!plainPassword)
        return null;
      try {
        if (!salt)
    Severity: Major
    Found in lib/common/auth.js and 1 other location - About 4 hrs to fix
    lib/common/index.js on lines 302..315

    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 118.

    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

    common.hashPassword = function (plainPassword, salt) {
      if (!plainPassword)
        return null;
      try {
        if (!salt)
    Severity: Major
    Found in lib/common/index.js and 1 other location - About 4 hrs to fix
    lib/common/auth.js on lines 726..739

    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 118.

    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 handleSocketIOConnection has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var handleSocketIOConnection = function(socket) {
        joola.connectCounter++;
    
        socket.on('error', function(err) {
          joola.events.emit('event_end');
    Severity: Major
    Found in lib/webserver/index.js - About 3 hrs to fix

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

      ZKDiscoveryProvider.prototype.get = function (key, callback) {
        var self = this;
        key = encodeURI(key).replace('.', '_$_');
        var result = self.common.flatGetSet(self._config, key.replace(/:/ig, '.'));
        if (callback && typeof callback === 'function')
      Severity: Major
      Found in lib/discovery/providers/zookeeper.js and 1 other location - About 3 hrs to fix
      lib/discovery/providers/redis.js on lines 72..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 107.

      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

      RedisDiscoveryProvider.prototype.get = function (key, callback) {
        var self = this;
        key = encodeURI(key).replace('.', '_$_');
        var result = self.common.flatGetSet(self._config, key.replace(/:/ig, '.'));
        if (callback && typeof callback === 'function')
      Severity: Major
      Found in lib/discovery/providers/redis.js and 1 other location - About 3 hrs to fix
      lib/discovery/providers/zookeeper.js on lines 159..166

      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 107.

      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 _route has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        _route: function(req, res) {
          var _params = {}; //req.parsed;
          var context = {};
          context.user = req.user;
          _params.workspace = context.user.workspace;
      Severity: Minor
      Found in lib/dispatch/beacon.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 parse has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      manager.parse = function(context, options, callback) {
        var query = joola.common.extend({}, options);
      
        if (!query.dimensions)
          query.dimensions = [];
      Severity: Minor
      Found in lib/dispatch/query.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

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

      exports.nopermission = {
        name: "/test/nopermission",
        description: "I make sure that tests run fine",
        inputs: [],
        _outputExample: {},
      Severity: Major
      Found in lib/dispatch/test.js and 1 other location - About 3 hrs to fix
      lib/dispatch/test.js on lines 15..29

      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 106.

      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

      exports.withpermission = {
        name: "/test/withpermission",
        description: "I make sure that tests run fine",
        inputs: [],
        _outputExample: {},
      Severity: Major
      Found in lib/dispatch/test.js and 1 other location - About 3 hrs to fix
      lib/dispatch/test.js on lines 31..45

      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 106.

      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 onevent has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          socket.onevent = function(packet) {
            var d = domain.create();
            var req = {};
            var res = {};
      
      
      Severity: Major
      Found in lib/webserver/index.js - About 3 hrs to fix

        Function startHTTP has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var startHTTP = function(callback) {
            self.http = http.createServer(app).listen(self.options.port, self.options.bind || '0.0.0.0', function(err) {
              /* istanbul ignore if */
              if (err)
                return callback(err);
        Severity: Major
        Found in lib/webserver/index.js - About 3 hrs to fix

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

            self.zookeeper.setData('/JOOLA', new Buffer(JSON.stringify(self._config)), function (err, stat) {
              self.zversion = stat.version;
              self.localChange = true;
              self.dispatch.emit('config:change', key);
              if (callback && typeof callback === 'function')
          Severity: Major
          Found in lib/discovery/providers/zookeeper.js and 1 other location - About 3 hrs to fix
          lib/discovery/providers/zookeeper.js on lines 150..156

          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 103.

          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

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

            self.zookeeper.setData('/JOOLA', new Buffer(JSON.stringify(self._config)), function (err, stat) {
              self.zversion = stat.version;
              self.localChange = true;
              self.dispatch.emit('config:change', key);
              if (callback && typeof callback === 'function')
          Severity: Major
          Found in lib/discovery/providers/zookeeper.js and 1 other location - About 3 hrs to fix
          lib/discovery/providers/zookeeper.js on lines 178..184

          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 103.

          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 init has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          config.init = function(callback) {
            var self = this;
            config.initialized = false;
            //base config object, following the require config has been parsed and available for the local node. May differ from central.
            config._config = require('config');
          Severity: Major
          Found in lib/discovery/index.js - About 3 hrs to fix

            Function init has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            dispatch.init = function (callback) {
              try {
                var self = dispatch;
            
                self.namespace = 'dispatch';
            Severity: Minor
            Found in lib/dispatch/index.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 request has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var request = function(firstRun, callback) {
                  //_params.options.timeframe.end.setMilliseconds(0);
                  if (!firstRun && lastQueryEndDate && timestampDimension) {
                    _params.options[0].timeframe_force_start = lastQueryEndDate;
            
            
            Severity: Major
            Found in lib/dispatch/query.js - About 3 hrs to fix

              Function parse has 78 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              manager.parse = function(context, options, callback) {
                var query = joola.common.extend({}, options);
              
                if (!query.dimensions)
                  query.dimensions = [];
              Severity: Major
              Found in lib/dispatch/query.js - About 3 hrs to fix

                Function sanitize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                common.sanitize = function (obj, proto, leavePrivate) {
                  var cleanup = function (elem) {
                    var result = {};
                    Object.keys(elem).forEach(function (key) {
                      if (!leavePrivate) {
                Severity: Minor
                Found in lib/common/index.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

                Severity
                Category
                Status
                Source
                Language