TryGhost/Ghost

View on GitHub
ghost/core/core/server/models/user.js

Summary

Maintainability
F
1 wk
Test Coverage

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

const _ = require('lodash');
const validator = require('@tryghost/validator');
const ObjectId = require('bson-objectid').default;
const ghostBookshelf = require('./base');
const baseUtils = require('./base/utils');
Severity: Major
Found in ghost/core/core/server/models/user.js - About 1 day to fix

    Function permissible has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
            const self = this;
            const userModel = userModelOrId;
            let origArgs;
    
    
    Severity: Minor
    Found in ghost/core/core/server/models/user.js - About 5 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 permissible has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
            const self = this;
            const userModel = userModelOrId;
            let origArgs;
    
    
    Severity: Major
    Found in ghost/core/core/server/models/user.js - About 4 hrs to fix

      Function edit has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          edit: function edit(data, unfilteredOptions) {
              const options = this.filterOptions(unfilteredOptions, 'edit');
              const self = this;
              const ops = [];
      
      
      Severity: Major
      Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

        Function onSaving has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            onSaving: function onSaving(newPage, attr, options) {
                const self = this;
                const tasks = [];
                let passwordValidation = {};
        
        
        Severity: Major
        Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

          `` has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          User = ghostBookshelf.Model.extend({
          
              tableName: 'users',
          
              actionsCollectCRUD: true,
          Severity: Minor
          Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

            Function onSaving has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                onSaving: function onSaving(newPage, attr, options) {
                    const self = this;
                    const tasks = [];
                    let passwordValidation = {};
            
            
            Severity: Minor
            Found in ghost/core/core/server/models/user.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 add has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                add: function add(dataToClone, unfilteredOptions) {
                    const options = this.filterOptions(unfilteredOptions, 'add');
                    const self = this;
                    const data = _.cloneDeep(dataToClone);
                    let userData = this.filterData(data);
            Severity: Major
            Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

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

                  transferOwnership: function transferOwnership(object, unfilteredOptions) {
                      const options = ghostBookshelf.Model.filterOptions(unfilteredOptions, 'transferOwnership');
                      let ownerRole;
                      let contextUser;
              
              
              Severity: Major
              Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

                Function update has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        ops.push(function update() {
                            return ghostBookshelf.Model.edit.call(self, data, options).then(async (user) => {
                                let roleId;
                
                                if (!data.roles || !data.roles.length) {
                Severity: Minor
                Found in ghost/core/core/server/models/user.js - About 1 hr to fix

                  Function check has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      check: function check(object) {
                          const self = this;
                  
                          return this.getByEmail(object.email)
                              .then((user) => {
                  Severity: Minor
                  Found in ghost/core/core/server/models/user.js - About 1 hr to fix

                    Function edit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        edit: function edit(data, unfilteredOptions) {
                            const options = this.filterOptions(unfilteredOptions, 'edit');
                            const self = this;
                            const ops = [];
                    
                    
                    Severity: Minor
                    Found in ghost/core/core/server/models/user.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 findOne has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        findOne: function findOne(dataToClone, unfilteredOptions) {
                            const options = this.filterOptions(unfilteredOptions, 'findOne');
                            let query;
                            let status;
                            let data = _.cloneDeep(dataToClone);
                    Severity: Minor
                    Found in ghost/core/core/server/models/user.js - About 1 hr to fix

                      Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                      Severity: Major
                      Found in ghost/core/core/server/models/user.js - About 50 mins to fix

                        Function getEmailAlertUsers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            getEmailAlertUsers(type, options) {
                                options = options || {};
                        
                                let filter = 'status:active';
                                if (type === 'free-signup') {
                        Severity: Minor
                        Found in ghost/core/core/server/models/user.js - About 35 mins 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 extraFilters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            extraFilters: function extraFilters(options) {
                                if (!options.status) {
                                    return null;
                                }
                        
                        
                        Severity: Minor
                        Found in ghost/core/core/server/models/user.js - About 35 mins 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

                        Avoid too many return statements within this function.
                        Open

                                            return Promise.reject(new errors.NoPermissionError({
                                                message: tpl(messages.notEnoughPermission)
                                            }));
                        Severity: Major
                        Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                                  return Promise.reject(
                                                      new errors.ValidationError({
                                                          message: tpl(messages.invalidRoleValue.message),
                                                          context: tpl(messages.invalidRoleValue.context),
                                                          help: tpl(messages.invalidRoleValue.help)
                          Severity: Major
                          Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return User.getOwnerUser()
                                            .then((owner) => {
                                                // CASE: owner can assign role to any user
                                                if (context.user === owner.id) {
                                                    if (hasUserPermission && hasApiKeyPermission) {
                            Severity: Major
                            Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return Promise.resolve();
                              Severity: Major
                              Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                        return Promise.resolve();
                                Severity: Major
                                Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return Promise.reject(new errors.NoPermissionError({
                                              message: tpl(messages.notEnoughPermission)
                                          }));
                                  Severity: Major
                                  Found in ghost/core/core/server/models/user.js - About 30 mins to fix

                                    Function onUpdated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        onUpdated: function onUpdated(model, options) {
                                            ghostBookshelf.Model.prototype.onUpdated.apply(this, arguments);
                                    
                                            model.statusChanging = model.get('status') !== model.previous('status');
                                            model.isActive = _.includes(activeStates, model.get('status'));
                                    Severity: Minor
                                    Found in ghost/core/core/server/models/user.js - About 25 mins 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 findOne has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        findOne: function findOne(dataToClone, unfilteredOptions) {
                                            const options = this.filterOptions(unfilteredOptions, 'findOne');
                                            let query;
                                            let status;
                                            let data = _.cloneDeep(dataToClone);
                                    Severity: Minor
                                    Found in ghost/core/core/server/models/user.js - About 25 mins 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

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

                                            if (_.isNumber(userModelOrId) || _.isString(userModelOrId)) {
                                                // Grab the original args without the first one
                                                origArgs = _.toArray(arguments).slice(1);
                                    
                                                // Get the actual user model
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 5 hrs to fix
                                    ghost/core/core/server/models/relations/authors.js on lines 316..333

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

                                    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

                                        countRelations() {
                                            return {
                                                posts(modelOrCollection, options) {
                                                    modelOrCollection.query('columns', 'users.*', (qb) => {
                                                        qb.count('posts.id')
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 5 hrs to fix
                                    ghost/core/core/server/models/tag.js on lines 170..188

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

                                    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

                                        destroy: function destroy(unfilteredOptions) {
                                            const options = this.filterOptions(unfilteredOptions, 'destroy', {extraAllowedProperties: ['id']});
                                    
                                            const destroyUser = () => {
                                                return ghostBookshelf.Model.destroy.call(this, options);
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 4 hrs to fix
                                    ghost/core/core/server/models/post.js on lines 1431..1446

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

                                    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

                                        parse() {
                                            const attrs = ghostBookshelf.Model.prototype.parse.apply(this, arguments);
                                    
                                            ['profile_image', 'cover_image'].forEach((attr) => {
                                                if (attrs[attr]) {
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 2 hrs to fix
                                    ghost/core/core/server/models/posts-meta.js on lines 23..33

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

                                    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

                                                        } else {
                                                            return Promise.reject(
                                                                new errors.ValidationError({
                                                                    message: tpl(messages.invalidRoleValue.message),
                                                                    context: tpl(messages.invalidRoleValue.context),
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 1 hr to fix
                                    ghost/core/core/server/services/auth/passwordreset.js on lines 70..76

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

                                    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 (!_.some(currentRoles, {id: adminRole.id})) {
                                                        return Promise.reject(new errors.ValidationError({
                                                            message: tpl(messages.onlyAdmCanBeAssignedOwnerRole)
                                                        }));
                                                    }
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 1 hr to fix
                                    ghost/core/core/server/models/user.js on lines 1056..1060

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

                                    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 (!_.some(currentRoles, {id: ownerRole.id})) {
                                                        return Promise.reject(new errors.NoPermissionError({
                                                            message: tpl(messages.onlyOwnerCanTransferOwnerRole)
                                                        }));
                                                    }
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 1 hr to fix
                                    ghost/core/core/server/models/user.js on lines 1079..1083

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

                                    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

                                                        if (context.user === owner.id) {
                                                            if (hasUserPermission && hasApiKeyPermission) {
                                                                return Promise.resolve();
                                                            }
                                    
                                    
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 1 hr to fix
                                    ghost/core/core/server/models/invite.js on lines 56..64

                                    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

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

                                            if (options.columns) {
                                                options.columns = _.intersection(options.columns, this.prototype.permittedAttributes());
                                            }
                                    Severity: Minor
                                    Found in ghost/core/core/server/models/user.js and 1 other location - About 40 mins to fix
                                    ghost/core/core/server/models/base/plugins/crud.js on lines 163..165

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

                                    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