telepat-io/telepat-api

View on GitHub

Showing 33 of 119 total issues

File user.js has 787 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var express = require('express');
var router = express.Router();
var FB = require('facebook-node');
var Twitter = require('twitter');
var async = require('async');
Severity: Major
Found in controllers/user.js - About 1 day to fix

    Function objectACL has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    security.objectACL = function (accessControl) {
        return function(req, res, next) {
            if (!req.body || !Object.getOwnPropertyNames(req.body).length) {
                return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
            }
    Severity: Minor
    Found in controllers/security.js - About 4 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

    File object.js has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var express = require('express');
    var router = express.Router();
    var Models = require('telepat-models');
    var security = require('./security');
    var microtime = require('microtime-nodejs');
    Severity: Minor
    Found in controllers/object.js - About 4 hrs to fix

      File app.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var express = require('express');
      var bodyParser = require('body-parser');
      var http = require('http');
      var https = require('https');
      var urlParser = require('url');
      Severity: Minor
      Found in app.js - About 3 hrs to fix

        Function linkMiddlewaresAndRoutes has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var linkMiddlewaresAndRoutes = function(callback) {
            app.use('/proxy', security.applicationIdValidation);
            app.use('/proxy', security.apiKeyValidation);
        
            /**
        Severity: Major
        Found in app.js - About 3 hrs to fix

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

          var linkMiddlewaresAndRoutes = function(callback) {
              app.use('/proxy', security.applicationIdValidation);
              app.use('/proxy', security.apiKeyValidation);
          
              /**
          Severity: Minor
          Found in app.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 objectACL has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          security.objectACL = function (accessControl) {
              return function(req, res, next) {
                  if (!req.body || !Object.getOwnPropertyNames(req.body).length) {
                      return next(new Models.TelepatError(Models.TelepatError.errors.RequestBodyEmpty));
                  }
          Severity: Minor
          Found in controllers/security.js - About 1 hr to fix

            Function sendEmail has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function sendEmail(provider, from, to, subject, content) {
                var emailService = Object.keys(provider)[0];
                var apiKey = provider[emailService];
            
                if (emailService == 'mandrill') {
            Severity: Minor
            Found in controllers/user.js - About 1 hr to fix

              Function unless has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              var unless = function(paths, middleware) {
                  return function(req, res, next) {
                      var excluded = false;
                      for (var i=0; i<paths.length; i++) {
                          if (paths[i] === req.path) {
              Severity: Minor
              Found in controllers/user.js - About 45 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

                                      } else if (err)
                                          return next(err);
              Severity: Major
              Found in controllers/device.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if (!err) {
                                                    return res.status(200).json({status: 200, content: {identifier: req.body.id}});
                                                }
                Severity: Major
                Found in controllers/device.js - About 45 mins to fix

                  Function addAuthorFilters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function addAuthorFilters(channelObject, appSchema, mdl, userId) {
                      if (channelObject.filter) {
                          if (!channelObject.filter.and && !channelObject.filter.or) {
                              channelObject.filter.and = [];
                          }
                  Severity: Minor
                  Found in controllers/object.js - About 45 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

                  Function sendEmail has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function sendEmail(provider, from, to, subject, content) {
                  Severity: Minor
                  Found in controllers/user.js - About 35 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter, username']));
                    Severity: Major
                    Found in controllers/user.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return next(new Models.TelepatError(Models.TelepatError.errors.OperationNotAllowed));
                      Severity: Major
                      Found in controllers/security.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return next(new Models.TelepatError(Models.TelepatError.errors.ServerNotConfigured,
                                        ['twitter login provider']));
                        Severity: Major
                        Found in controllers/user.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return next(new Models.TelepatError(Models.TelepatError.errors.InvalidLoginProvider, ['facebook, twitter']));
                          Severity: Major
                          Found in controllers/user.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['password']));
                            Severity: Major
                            Found in controllers/user.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, [hasSomeProperty]));
                              Severity: Major
                              Found in controllers/object.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                return next(new Models.TelepatError(Models.TelepatError.errors.OperationNotAllowed));
                                Severity: Major
                                Found in controllers/security.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language