getlackey/lackey-cms

View on GitHub
modules/core/server/models/user/index.js

Summary

Maintainability
F
1 wk
Test Coverage

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

    .then((Taggable, Role, knex) => {

        SCli.debug(__MODULE_NAME, 'READY');

        /**
Severity: Major
Found in modules/core/server/models/user/index.js - About 4 days to fix

    File index.js has 853 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint no-underscore-dangle:0 */
    /* jslint node:true, esnext:true */
    /* globals LACKEY_PATH */
    'use strict';
    
    
    Severity: Major
    Found in modules/core/server/models/user/index.js - About 2 days to fix

      Function exports has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
      Open

          .then((Taggable, Role, knex) => {
      
              SCli.debug(__MODULE_NAME, 'READY');
      
              /**
      Severity: Minor
      Found in modules/core/server/models/user/index.js - About 1 day 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

      Consider simplifying this complex logical expression.
      Open

                              if (isNew && ret.length > 0) {
                                  throw(new Error('Identity already exists'));
                              } else {
                                  return objection.transaction(Identities, function (BoundIdentities) {
                                      return SCli
      Severity: Critical
      Found in modules/core/server/models/user/index.js - About 2 hrs to fix

        Function setIdentity has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    setIdentity(provider, id, accessToken, refreshToken, providerData, confirmed, isNew) {
        
                        SCli.debug(__MODULE_NAME, 'setIdentity', this.id, provider, id, accessToken, refreshToken, providerData, confirmed);
        
                        if (!this.id) {
        Severity: Minor
        Found in modules/core/server/models/user/index.js - About 1 hr to fix

          Function _postSave has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      _postSave(cached) {
          
                          SCli.debug(__MODULE_NAME, '_postSave');
          
                          let promise = super._postSave(cached),
          Severity: Minor
          Found in modules/core/server/models/user/index.js - About 1 hr to fix

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

                        static _preQuery(innerQuery, options) {
            
                            let query = innerQuery ? JSON.parse(JSON.stringify(innerQuery)) : {},
                                opts = options ? options : {};
            
            
            Severity: Minor
            Found in modules/core/server/models/user/index.js - About 1 hr to fix

              Function remove has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          remove() {
                              let self = this;
                              return Promise
                                  .all([
                                  SCli.sql(Identities
              Severity: Minor
              Found in modules/core/server/models/user/index.js - About 1 hr to fix

                Function _preSave has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            _preSave(options) {
                
                                if (this.preventSave) {
                                    throw new Error('Save prevention');
                                }
                Severity: Minor
                Found in modules/core/server/models/user/index.js - About 1 hr to fix

                  Function oAuthHandleNotLoggedIn has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              static oAuthHandleNotLoggedIn(provider, id, accessToken, refreshToken, providerData, userData) {
                  
                                  SCli.debug(__MODULE_NAME, 'oAuthHandleNotLoggedIn');
                  
                                  let self = this;
                  Severity: Minor
                  Found in modules/core/server/models/user/index.js - About 1 hr to fix

                    Avoid too many return statements within this function.
                    Open

                                    return super.create.apply(this, [data]);
                    Severity: Major
                    Found in modules/core/server/models/user/index.js - About 30 mins to fix

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

                                  invalidateToken(token) {
                      
                                      SCli.debug(__MODULE_NAME, 'invalidateToken');
                      
                                      let self = this;
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 day to fix
                      modules/core/server/models/user/index.js on lines 516..544

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

                      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

                                  invalidatePasswordToken(token) {
                      
                                      SCli.debug(__MODULE_NAME, 'invalidatePasswordToken');
                      
                                      let self = this;
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 day to fix
                      modules/core/server/models/user/index.js on lines 486..514

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

                      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

                                  removeOtherIdentity(provider, id) {
                      
                                      SCli.debug(__MODULE_NAME, 'removeOtherIdentity', provider, id);
                      
                                      return SCli
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 3 hrs to fix
                      modules/core/server/models/user/index.js on lines 1074..1088

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

                      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

                                  removeIdentity(provider, id) {
                      
                                      SCli.debug(__MODULE_NAME, 'removeIdentity', provider, id);
                      
                                      return SCli
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 3 hrs to fix
                      modules/core/server/models/user/index.js on lines 1090..1104

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

                      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 (cached.email) {
                                          promise = promise
                                              .then((user) => {
                                                  return user
                                                      .setIdentity(User.EMAIL, cached.email, null, null, null, cached.confirmed === true);
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 hr to fix
                      modules/core/server/models/user/index.js on lines 413..419

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

                      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 (cached.username) {
                                          promise = promise.then(
                                              (user) => {
                                                  return user
                                                      .setIdentity(User.USERNAME, cached.username, null, null, null, cached.confirmed === true);
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 hr to fix
                      modules/core/server/models/user/index.js on lines 406..412

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

                      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 (this._doc.username) {
                                          promise = promise
                                              .then(this
                                                  .bind(this._detectConflict, [User.USERNAME, this._doc.username]));
                                      }
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 hr to fix
                      modules/core/server/models/user/index.js on lines 294..298

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

                      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 (this._doc.email) {
                                          promise = promise
                                              .then(this
                                                  .bind(this._detectConflict, [User.EMAIL, this._doc.email]));
                                      }
                      Severity: Major
                      Found in modules/core/server/models/user/index.js and 1 other location - About 1 hr to fix
                      modules/core/server/models/user/index.js on lines 300..304

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

                      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

                                      return SUtils
                                          .cmsMod('core')
                                          .model('media')
                                          .then((Media) => {
                                              return Media.generator(imagePath);
                      Severity: Minor
                      Found in modules/core/server/models/user/index.js and 2 other locations - About 35 mins to fix
                      modules/core/server/models/user/index.js on lines 367..377
                      modules/users/server/auth/index.js on lines 28..38

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

                      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

                                          return SUtils
                                              .cmsMod('core')
                                              .model('media')
                                              .then((Media) => {
                                                  return Media.generator(image);
                      Severity: Minor
                      Found in modules/core/server/models/user/index.js and 2 other locations - About 35 mins to fix
                      modules/core/server/models/user/index.js on lines 321..330
                      modules/users/server/auth/index.js on lines 28..38

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status