thegameofcode/cipherlayer

View on GitHub

Showing 368 of 368 total issues

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

            async.series([
                function (done) {
                    //Add "realms" & "capabilities"
                    daoMng.getRealms(function (err, realms) {
                        if (err) {
Severity: Major
Found in src/routes_public/auth/login_post.js and 2 other locations - About 2 days to fix
src/platforms/salesforce.js on lines 178..222
src/routes_public/auth/renew_post.js on lines 61..103

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

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

            async.series([
                function (done) {
                    //Add 'realms' & 'capabilities'
                    daoMng.getRealms(function (err, realms) {
                        if (err) {
Severity: Major
Found in src/routes_public/auth/renew_post.js and 2 other locations - About 2 days to fix
src/platforms/salesforce.js on lines 178..222
src/routes_public/auth/login_post.js on lines 47..89

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

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

                async.series([
                    function (done) {
                        //Add "realms" & "capabilities"
                        daoMng.getRealms(function (err, realms) {
                            if (err) {
Severity: Major
Found in src/platforms/salesforce.js and 2 other locations - About 2 days to fix
src/routes_public/auth/login_post.js on lines 47..89
src/routes_public/auth/renew_post.js on lines 61..103

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

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

        server.on('after', function (req, res) {
            const logInfo = {
                request: {
                    method: req.method,
                    headers: req.headers,
Severity: Major
Found in src/internal_service.js and 1 other location - About 1 day to fix
src/public_service.js on lines 39..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 239.

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

        server.on('after', function (req, res) {
            const logInfo = {
                request: {
                    method: req.method,
                    headers: req.headers,
Severity: Major
Found in src/public_service.js and 1 other location - About 1 day to fix
src/internal_service.js on lines 28..54

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

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

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

                                                    tokenMng.createBothTokens(foundUser._id, data, function (err, tokens) {
                                                        if (err) {
                                                            log.error({err}, 'error creating tokens');
                                                            return cbk({
                                                                err: err.message,
                        Severity: Major
                        Found in src/managers/user.js and 1 other location - About 3 hrs to fix
                        src/managers/user.js on lines 395..405

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

                        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

                                                tokenMng.createBothTokens(foundUser._id, data, function (err, tokens) {
                                                    if (err) {
                                                        log.error({err}, 'error creating tokens');
                                                        return cbk({
                                                            err: err.message,
                        Severity: Major
                        Found in src/managers/user.js and 1 other location - About 3 hrs to fix
                        src/managers/user.js on lines 248..258

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

                        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 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
                            Severity
                            Category
                            Status
                            Source
                            Language