thegameofcode/cipherlayer

View on GitHub

Showing 368 of 368 total issues

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

            function (done) {
                realmsCollection = connectedDb.collection('realms');
                async.series([
                    function (next) {
                        realmsCollection.ensureIndex('_id', next);
Severity: Major
Found in src/managers/dao.js and 1 other location - About 2 hrs to fix
src/managers/dao.js on lines 35..48

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

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

            function (done) {
                usersCollection = connectedDb.collection('users');
                async.series([
                    function (next) {
                        usersCollection.ensureIndex('_id', next);
Severity: Major
Found in src/managers/dao.js and 1 other location - About 2 hrs to fix
src/managers/dao.js on lines 49..62

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

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

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

    module.exports = function (req, res, next) {
        userMng().removeRealmFromUser(req.user._id, req.body.name, function (err) {
            if( err ) return responseError(err, res, next);
    
            res.send(200);
    Severity: Major
    Found in src/routes_internal/user/removeUserRealm_del.js and 1 other location - About 2 hrs to fix
    src/routes_internal/user/addUserRealm_post.js on lines 6..13

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

    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

    module.exports = function (req, res, next) {
        userMng().addRealmToUser(req.user._id, req.body.name, function (err) {
            if( err ) return responseError(err, res, next);
    
            res.send(204);
    Severity: Major
    Found in src/routes_internal/user/addUserRealm_post.js and 1 other location - About 2 hrs to fix
    src/routes_internal/user/removeUserRealm_del.js on lines 6..13

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

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

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

                const options = {
                    url: _settings.externalServices.notifications.base + _settings.externalServices.notifications.pathEmail,
                    headers: {
                        'Content-Type': 'application/json; charset=utf-8'
                    },
            Severity: Major
            Found in src/managers/email.js and 1 other location - About 1 hr to fix
            src/managers/email.js on lines 100..107

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

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

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

                const options = {
                    url: _settings.externalServices.notifications.base + _settings.externalServices.notifications.pathEmail,
                    headers: {
                        'Content-Type': 'application/json; charset=utf-8'
                    },
            Severity: Major
            Found in src/managers/email.js and 1 other location - About 1 hr to fix
            src/managers/email.js on lines 135..142

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

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

                service.start = function (internalPort, done) {
                    if (!internalPort) {
                        log.info('INTERNAL SERVICE not started because there is no internal_port in config');
                        return done();
                    }
            Severity: Minor
            Found in src/internal_service.js - About 1 hr to fix

              Function renewSFAccessTokenIfNecessary has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function renewSFAccessTokenIfNecessary(user, platform, cbk) {
                  const maxTimeTillRenewal = (new Date().getTime() + config.salesforce.renewWhenLessThan * 60 * 1000);
                  if (platform.expiry > maxTimeTillRenewal) {
                      return cbk(null, platform.accessToken.params.access_token);
                  }
              Severity: Minor
              Found in src/platforms/salesforce.js - About 1 hr to fix

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

                function getRefreshTokenInfo(refreshToken, cbk) {
                    try {
                        ciphertoken.getTokenSet(refreshTokenSettings, refreshToken, cbk);
                    } catch (err){
                        log.error({err_info: err, refresh_token: refreshToken}, 'error getting refreshToken info');
                Severity: Major
                Found in src/managers/token.js and 1 other location - About 1 hr to fix
                src/managers/token.js on lines 33..41

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

                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

                function getAccessTokenInfo(accessToken, cbk) {
                    try {
                        ciphertoken.getTokenSet(accessTokenSettings, accessToken, cbk);
                    } catch(err) {
                        log.error({err_info: err, access_token: accessToken}, 'error getting accessToken info');
                Severity: Major
                Found in src/managers/token.js and 1 other location - About 1 hr to fix
                src/managers/token.js on lines 43..50

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

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

                function pinValidation(req, res, next) {
                    if (!_settings.phoneVerification || !_settings.phoneVerification.pinValidationEndpoints) {
                        return next();
                    }
                
                
                Severity: Minor
                Found in src/middlewares/pinValidation.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

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

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

                  function createRefreshToken(userId, dataIn, cbkIn) {
                      let data = dataIn;
                      let cbk = cbkIn;
                      if (isFunction(dataIn)) {
                          cbk = data;
                  Severity: Major
                  Found in src/managers/token.js and 1 other location - About 1 hr to fix
                  src/managers/token.js on lines 22..31

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

                  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