RackHD/on-http

View on GitHub
lib/services/account-api-service.js

Summary

Maintainability
F
3 days
Test Coverage

Function accountApiServiceFactory has 251 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function accountApiServiceFactory(
    waterline,
    Errors,
    Logger,
    _,
Severity: Major
Found in lib/services/account-api-service.js - About 1 day to fix

    File account-api-service.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2016, EMC, Inc.
    
    'use strict';
    
    var di = require('di'),
    Severity: Minor
    Found in lib/services/account-api-service.js - About 2 hrs to fix

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

          AccountApiService.prototype.start = function() {
              var acl = this.acl;
              var self = this;
              var endpoints = configuration.get('httpEndpoints', []);
              var authEnabled = _(endpoints).filter(function(endpoint) {
      Severity: Minor
      Found in lib/services/account-api-service.js - About 1 hr to fix

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

            AccountApiService.prototype.modifyUserByName = function(name, info) {
                var self = this;
                return Promise.try(function() {
                    assert.string(name);
                    return waterline.localusers.findOne({username: name});
        Severity: Minor
        Found in lib/services/account-api-service.js - About 1 hr to fix

          Function accountApiServiceFactory has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              waterline,
              Errors,
              Logger,
              _,
              Promise,
          Severity: Major
          Found in lib/services/account-api-service.js - About 1 hr to fix

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

                    return Promise.try(function () {
                        assert.string(name);
                    })
                    .then(function () {
                        return waterline.roles.findOne({ role: name });
            Severity: Major
            Found in lib/services/account-api-service.js and 1 other location - About 1 hr to fix
            lib/services/account-api-service.js on lines 180..194

            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

                    return Promise.try(function() {
                        assert.string(name);
                    })
                    .then(function() {
                        return waterline.localusers.findOne({username: name});
            Severity: Major
            Found in lib/services/account-api-service.js and 1 other location - About 1 hr to fix
            lib/services/account-api-service.js on lines 256..270

            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

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

                        return Promise.props({
                            id: user.id,
                            username: user.username,
                            role: user.role,
                            privileges: self.aclMethod('_rolesParents', [user.role])
            Severity: Major
            Found in lib/services/account-api-service.js and 1 other location - About 1 hr to fix
            lib/services/account-api-service.js on lines 94..99

            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

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

                        return Promise.props({
                            id: user.id,
                            username: user.username,
                            role: user.role,
                            privileges: self.aclMethod('_rolesParents', [user.role])
            Severity: Major
            Found in lib/services/account-api-service.js and 1 other location - About 1 hr to fix
            lib/services/account-api-service.js on lines 113..118

            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 4 locations. Consider refactoring.
            Open

                    return Promise.try(function() {
                        assert.string(username);
                        return waterline.localusers.findOne({username: username});
                    })
                    .then(function(user) {
            Severity: Major
            Found in lib/services/account-api-service.js and 3 other locations - About 50 mins to fix
            lib/services/account-api-service.js on lines 151..163
            lib/services/account-api-service.js on lines 229..241
            lib/services/account-api-service.js on lines 281..290

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

            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 4 locations. Consider refactoring.
            Open

                    return Promise.try(function() {
                        assert.string(name);
                        return waterline.localusers.findOne({username: name});
                    })
                    .then(function(entry) {
            Severity: Major
            Found in lib/services/account-api-service.js and 3 other locations - About 50 mins to fix
            lib/services/account-api-service.js on lines 105..119
            lib/services/account-api-service.js on lines 229..241
            lib/services/account-api-service.js on lines 281..290

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

            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 4 locations. Consider refactoring.
            Open

                    return Promise.try(function () {
                        assert.string(name);
                        return waterline.roles.findOne({ role: name });
                    })
                    .then(function (roleFound) {
            Severity: Major
            Found in lib/services/account-api-service.js and 3 other locations - About 50 mins to fix
            lib/services/account-api-service.js on lines 105..119
            lib/services/account-api-service.js on lines 151..163
            lib/services/account-api-service.js on lines 281..290

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

            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(info.role && info.role !== entry.role) {
                            return [entry, self.aclMethod('addUserRoles', entry.username, info.role)];
                        }
            Severity: Minor
            Found in lib/services/account-api-service.js and 1 other location - About 50 mins to fix
            lib/services/account-api-service.js on lines 159..161

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

            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(info.role && info.role !== entry.role) {
                            return [entry, self.aclMethod('removeUserRoles', entry.username, entry.role)];
                        }
            Severity: Minor
            Found in lib/services/account-api-service.js and 1 other location - About 50 mins to fix
            lib/services/account-api-service.js on lines 168..170

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

            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 4 locations. Consider refactoring.
            Open

                    return Promise.try(function () {
                        assert.string(name);
                        return waterline.roles.findOne({ role: name });
                    })
                    .then(function (entry) {
            Severity: Major
            Found in lib/services/account-api-service.js and 3 other locations - About 50 mins to fix
            lib/services/account-api-service.js on lines 105..119
            lib/services/account-api-service.js on lines 151..163
            lib/services/account-api-service.js on lines 229..241

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

            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