Showing 258 of 258 total issues

Function init has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

datastore.init = function(callback) {
  //find out what datastores we have in config
  var stores = joola.config.get('store:datastore');
  if (!stores)
    return callback(null);
Severity: Major
Found in lib/common/datastore.js - About 2 hrs to fix

    Function checkRateLimits has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    auth.checkRateLimits = function (req, res, callback) {
      var limitKey;
      if (!req.user) {
        limitKey = req.connection.remoteAddress;
        req.limits = {
    Severity: Major
    Found in lib/common/auth.js - About 2 hrs to fix

      Function validateAction has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      auth.validateAction = function (action, req, res, callback) {
        if (req.method == 'OPTIONS')
          return process.nextTick(function () {
            return callback(null, true);
          });
      Severity: Major
      Found in lib/common/auth.js - About 2 hrs to fix

        Function processRequest has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        dispatch.processRequest = function (message, headers) {
          message = message[0];
          message = JSON.parse(message).message;
        
          var _result;
        Severity: Major
        Found in lib/dispatch/index.js - About 2 hrs to fix

          Function once has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          dispatch.once = function (channel, callback, next) {
            callback = callback || function () {
            };
          
            var exists = _.find(dispatch.listeners, function (listener) {
          Severity: Minor
          Found in lib/dispatch/index.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 run has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            run: function(context, workspace, collection, documents, options, callback) {
          
              if (typeof options === 'function') {
                callback = options;
                options = {};
          Severity: Major
          Found in lib/dispatch/beacon.js - About 2 hrs to fix

            Function ZKDiscoveryProvider has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function ZKDiscoveryProvider(options, helpers, callback) {
              if (!(this instanceof ZKDiscoveryProvider)) return new ZKDiscoveryProvider(options, helpers, callback);
              callback = callback || function () {
              };
              var self = this;
            Severity: Major
            Found in lib/discovery/providers/zookeeper.js - About 2 hrs to fix

              Function generateToken has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              auth.generateToken = function (req, user, callback) {
                /* istanbul ignore if */
                if (!callback) {
                  callback = user;
                  user = req;
              Severity: Major
              Found in lib/common/auth.js - About 2 hrs to fix

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

                    if (!fs.existsSync(self.options.certfile)) {
                      joola.logger.error('SSL certificate file missing: ' + self.options.certfile);
                      return callback(new Error('SSL certificate file missing: ' + self.options.certfile));
                    }
                Severity: Major
                Found in lib/webserver/index.js and 1 other location - About 2 hrs to fix
                lib/webserver/index.js on lines 394..397

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

                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

                    if (!fs.existsSync(self.options.keyfile)) {
                      joola.logger.error('SSL key file missing: ' + self.options.keyfile);
                      return callback(new Error('SSL key file missing: ' + self.options.keyfile));
                    }
                Severity: Major
                Found in lib/webserver/index.js and 1 other location - About 2 hrs to fix
                lib/webserver/index.js on lines 399..402

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

                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 index.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /**
                 *  @title joola
                 *  @overview the open-source data analytics framework
                 *  @copyright Joola Smart Solutions, Ltd. <info@joo.la>
                 *  @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
                Severity: Minor
                Found in lib/common/index.js - About 2 hrs to fix

                  Function parseDimension has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  manager.parseDimension = function(context, d, callback) {
                    var col;
                    var dimension = {};
                  
                    if (!d)
                  Severity: Major
                  Found in lib/dispatch/query.js - About 2 hrs to fix

                    Function load has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    etl.load = function(context, workspace, collection, documents, options, callback) {
                      joola.dispatch.collections.metadata(context, workspace, collection, ce.clone(documents[0]), function(err, meta, _collection) {
                        if (err)
                          return callback(err);
                    
                    
                    Severity: Major
                    Found in lib/dispatch/beacon.js - About 2 hrs to fix

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

                          joola.config.get('workspaces:' + workspace + ':roles:' + rolename, function (err, value) {
                            /* istanbul ignore if */
                            if (err)
                              return callback(err);
                      
                      
                      Severity: Major
                      Found in lib/dispatch/roles.js and 1 other location - About 2 hrs to fix
                      lib/dispatch/workspaces.js on lines 123..133

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

                      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

                          joola.config.get('workspaces:' + key, function (err, value) {
                            /* istanbul ignore if */
                            if (err)
                              return callback(err);
                      
                      
                      Severity: Major
                      Found in lib/dispatch/workspaces.js and 1 other location - About 2 hrs to fix
                      lib/dispatch/roles.js on lines 122..132

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

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

                      joola.nodeState = function () {
                        var hostname = joola.hostname = os.hostname();
                        var osDetails = {
                          type: os.type(),
                          platform: os.platform(),
                      Severity: Major
                      Found in lib/common/globals.js - About 2 hrs to fix

                        Function run has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          run: function(context, options, callback) {
                            callback = callback || function() {};
                            var wasArray = true;
                            if (!Array.isArray(options)) {
                              options = [options];
                        Severity: Major
                        Found in lib/dispatch/query.js - About 2 hrs to fix

                          Function getUserByToken has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          auth.getUserByToken = function (token, callback) {
                            callback = callback || function () {
                            };
                            if (!token)
                              return process.nextTick(function () {
                          Severity: Major
                          Found in lib/common/auth.js - About 2 hrs to fix

                            Function _route has 49 lines of code (exceeds 25 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 1 hr to fix

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

                                  if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
                                    err = new Error('Forbidden');
                                    err.code = 403;
                                    return callback(err);
                                  }
                              Severity: Major
                              Found in lib/dispatch/users.js and 1 other location - About 1 hr to fix
                              lib/dispatch/users.js on lines 447..451

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language