thegameofcode/cipherlayer

View on GitHub

Showing 368 of 368 total issues

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

function createAccessToken(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 52..60

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

Function emailVerification has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function emailVerification(email, bodyData, cbk) {
    if (!_settings.emailVerification) {
        return cbk(null, null);
    }

Severity: Minor
Found in src/managers/email.js - About 1 hr to fix

    Function prepareSession has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function prepareSession(accessToken, refreshToken, profile, done) {
        log.info(`user ${profile.id} logged in using salesforce`);
        async.series([
                function uploadAvatar(done) {
                    if (!profile._raw || !profile._raw.photos || !profile._raw.photos.picture || !config.aws || !config.aws.buckets || !config.aws.buckets.avatars) {
    Severity: Minor
    Found in src/platforms/salesforce.js - About 1 hr to fix

      Function connect has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function connect(cbk) {
          MongoClient.connect(MONGODB_URI, function (err, connectedDb) {
              assert.equal(err, null, err);
              db = connectedDb;
      
      
      Severity: Minor
      Found in src/managers/dao.js - About 1 hr to fix

        Function isValidDomain has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function isValidDomain(email, cbk) {
            // settings overrides realms configuration
            if (_settings.allowedDomains) {
                for (let i = 0; i < _settings.allowedDomains.length; i++) {
                    const domain = _settings.allowedDomains[i];
        Severity: Minor
        Found in src/managers/user.js - About 1 hr to fix

          Function addUser has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addUser(userToAdd, cbk) {
              const user = _.clone(userToAdd);
          
              if (!user.id) {
                  return cbk({err: 'invalid_id'}, null);
          Severity: Minor
          Found in src/managers/dao.js - About 1 hr to fix

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

            module.exports = function (req, res, next) {
            
                const email = req.params.email;
            
                if (!email) {
            Severity: Minor
            Found in src/routes_public/auth/loginEmail_post.js - About 1 hr to fix

              Function addRealmToUser has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function addRealmToUser(userId, name, cbk) {
                  async.waterfall([
                      function (done) {
                          daoMng.getRealmFromName(name, function (err, realm) {
                              if (err) {
              Severity: Minor
              Found in src/managers/user.js - About 1 hr to fix

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

                    if (!validatePwd(body.password, _settings.password.regexValidation)) {
                        const err = ERR_INVALID_PWD;
                        err.des = _settings.password.message;
                        return cbk(err);
                    }
                Severity: Major
                Found in src/managers/user.js and 1 other location - About 1 hr to fix
                src/managers/user.js on lines 74..78

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

                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 (!validatePwd(body.password, _settings.password.regexValidation)) {
                                const invalidPasswordError = ERR_INVALID_PWD;
                                invalidPasswordError.des = _settings.password.message;
                                return cbk(invalidPasswordError);
                            }
                Severity: Major
                Found in src/managers/user.js and 1 other location - About 1 hr to fix
                src/managers/user.js on lines 424..428

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

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

                function uploadAvatarToAWS(httpsAvatarUrl, avatarName, cbk) {
                
                    const validBucket = config.aws.buckets.avatars;
                
                    https.get(httpsAvatarUrl, function (res) {
                Severity: Minor
                Found in src/managers/file_store.js - About 1 hr to fix

                  Function sendEmailMagicLink has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function sendEmailMagicLink(email, link, cbk){
                  
                      const html = _settings.magicLink.body.replace('__LINK__', link);
                  
                      const body = {
                  Severity: Minor
                  Found in src/managers/email.js - About 1 hr to fix

                    Function addFixture has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const addFixture = function (fixture, callback) {
                    
                        const data = fixture;
                    
                        // Define user object to be passed to userMng
                    Severity: Minor
                    Found in scripts/add_users.js - About 1 hr to fix

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

                                                  if (redisPinAttempts === '1') {
                                                      createPIN(redisKeyId, formattedPhone, function (err) {
                                                          if (err) {
                                                              return cbk(err);
                                                          }
                      Severity: Major
                      Found in src/managers/phone.js and 2 other locations - About 1 hr to fix
                      src/managers/phone.js on lines 97..150
                      src/managers/phone.js on lines 111..148

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

                      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

                                      if (!redisPhonePin) {
                                          createPIN(redisKeyId, formattedPhone, function (err) {
                                              if (err) {
                                                  return cbk(err);
                                              }
                      Severity: Major
                      Found in src/managers/phone.js and 2 other locations - About 1 hr to fix
                      src/managers/phone.js on lines 111..148
                      src/managers/phone.js on lines 127..147

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

                      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

                                              if (!redisPinAttempts || redisPinAttempts === '0') {
                                                  createPIN(redisKeyId, formattedPhone, function (err) {
                                                      if (err) {
                                                          return cbk(err);
                                                      }
                      Severity: Major
                      Found in src/managers/phone.js and 2 other locations - About 1 hr to fix
                      src/managers/phone.js on lines 97..150
                      src/managers/phone.js on lines 127..147

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

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

                      function sendEmailForgotPassword(email, passwd, link, cbk) {
                      
                          const html = _settings.password.body.replace('__PASSWD__', passwd).replace('__LINK__', link);
                      
                          const body = {
                      Severity: Minor
                      Found in src/managers/email.js - About 1 hr to fix

                        Function checkPermissions has 26 lines of code (exceeds 25 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

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

                          module.exports = function (req, res, next) {
                              userMng().createUser(req.body, req.headers['x-otp-pin'], function (error, tokens) {
                                  if (error) {
                                      if (!error.code) {
                                          res.send(500, error);
                          Severity: Minor
                          Found in src/routes_public/user/createUser_post.js - About 1 hr to fix

                            Function postAuthUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports = function postAuthUser(req, res, next) {
                                const user = {
                                    id: req.body.id,
                                    username: req.body.username,
                                    password: req.body.password
                            Severity: Minor
                            Found in src/routes_internal/auth/user_post.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language