thegameofcode/cipherlayer

View on GitHub

Showing 51 of 368 total issues

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

'use strict';

const request = require('request');
const _ = require('lodash');
const ciphertoken = require('ciphertoken');
Severity: Minor
Found in src/managers/user.js - About 7 hrs to fix

    Function salesforceCallback has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function salesforceCallback(req, res, next) {
        const sfData = req.user;
        const profile = sfData.profile;
    
        daoMng.getFromUsername(profile._raw.email, function (err, foundUser) {
    Severity: Major
    Found in src/platforms/salesforce.js - About 5 hrs to fix

      Function createUserPrivateCall has 117 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createUserPrivateCall(body, user, cbk) {
          const clonedBody = _.clone(body);
          delete clonedBody.password;
          const options = {
              url: `http://${_settings.private_host}:${_settings.private_port}${_settings.passThroughEndpoint.path}`,
      Severity: Major
      Found in src/managers/user.js - About 4 hrs to fix

        Function exports has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function () {
        
            service.start = function (publicPort, done) {
                server = restify.createServer({
                    name: 'cipherlayer-server',
        Severity: Major
        Found in src/public_service.js - About 4 hrs to fix

          Function createUserByToken has 101 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createUserByToken(token, cbk) {
              if (!token) {
                  return cbk({
                      err: 'auth_proxy_error',
                      des: 'empty param verifyToken',
          Severity: Major
          Found in src/managers/user.js - About 4 hrs to fix

            Function postAuthRegisterFacebook has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function postAuthRegisterFacebook(req, res, next) {
            
                const options = _.clone(defaultOptions);
                options.qs.access_token = req.body.accessToken;
            
            
            Severity: Major
            Found in src/routes_public/auth/loginFacebook_post.js - About 4 hrs to fix

              Function start has 99 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  service.start = function (publicPort, done) {
                      server = restify.createServer({
                          name: 'cipherlayer-server',
                          log
                      });
              Severity: Major
              Found in src/public_service.js - About 3 hrs to fix

                Function createUser has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function createUser(body, pin, cbk) {
                    if (!body[_settings.passThroughEndpoint.username]) {
                        return cbk({
                            err: 'auth_proxy_error',
                            des: 'invalid userinfo',
                Severity: Major
                Found in src/managers/user.js - About 3 hrs to fix

                  Function exports has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function (req, res, next) {
                      const refreshToken = req.body.refreshToken;
                      const data = {};
                  
                      if (req.body.deviceId) {
                  Severity: Major
                  Found in src/routes_public/auth/renew_post.js - About 3 hrs to fix

                    Function verifyPhone has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function verifyPhone(redisKeyId, phone, country, pin, cbk) {
                        if (!_settings.phoneVerification) {
                            return cbk(null, true);
                        }
                    
                    
                    Severity: Major
                    Found in src/managers/phone.js - About 3 hrs to fix

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

                      module.exports = function (req, res, next) {
                          if (!req.params.email) {
                              res.send(400, {
                                  err: 'auth_proxy_error',
                                  des: 'empty email'
                      Severity: Major
                      Found in src/routes_public/user/forgotPassword_get.js - About 3 hrs to fix

                        Function exports has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function (req, res, next) {
                            const userAgent = String(req.headers['user-agent']);
                        
                            cryptoMng.encrypt(req.body.password, function (encryptedPwd) {
                                daoMng.getFromUsernamePassword(req.body.username, encryptedPwd, function (err, foundUser) {
                        Severity: Major
                        Found in src/routes_public/auth/login_post.js - About 3 hrs to fix

                          File dao.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          'use strict';
                          
                          const assert = require('assert');
                          const async = require('async');
                          const escapeRegexp = require('escape-regexp');
                          Severity: Minor
                          Found in src/managers/dao.js - About 3 hrs to fix

                            File salesforce.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            'use strict';
                            
                            const log = require('../logger/service');
                            const request = require('request');
                            const async = require('async');
                            Severity: Minor
                            Found in src/platforms/salesforce.js - About 2 hrs to fix

                              Function pinValidation has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function pinValidation(req, res, next) {
                                  if (!_settings.phoneVerification || !_settings.phoneVerification.pinValidationEndpoints) {
                                      return next();
                                  }
                              
                              
                              Severity: Major
                              Found in src/middlewares/pinValidation.js - About 2 hrs to fix

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

                                function prepareOptions(req, res, next) {
                                
                                    const options = {
                                        url: `http://${config.private_host}:${config.private_port}${req.url}`,
                                        headers: {
                                Severity: Minor
                                Found in src/middlewares/prepareOptions.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 exports has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = function () {
                                    const service = {};
                                
                                    let server;
                                    service.start = function (internalPort, done) {
                                Severity: Major
                                Found in src/internal_service.js - About 2 hrs to fix

                                  Function exports has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function (req, res, next) {
                                      if (!req.params) {
                                          res.send(400, {
                                              err: 'invalid_url_params',
                                              des: 'The call to this url must have params.'
                                  Severity: Major
                                  Found in src/routes_public/user/activateUser_get.js - About 2 hrs to fix

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

                                    function propagateRequest(req, res, next) {
                                        const start = Date.now();
                                    
                                        const useDirectProxy = _.some(config.directProxyUrls, function (pattern) {
                                            return req.url.match(new RegExp(pattern, 'g'));
                                    Severity: Major
                                    Found in src/middlewares/propagateRequest.js - About 2 hrs to fix

                                      Function checkPermissions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      module.exports = function checkPermissions(req, res, next) {
                                          if (!config.endpoints) {
                                              return next();
                                          }
                                      
                                      
                                      Severity: Minor
                                      Found in src/middlewares/permissions.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language