RackHD/on-http

View on GitHub
lib/services/sku-pack-service.js

Summary

Maintainability
F
1 wk
Test Coverage

Function skuPackServiceFactory has 516 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function skuPackServiceFactory(
    _,
    waterline,
    Logger,
    FileLoader,
Severity: Major
Found in lib/services/sku-pack-service.js - About 2 days to fix

    File sku-pack-service.js has 564 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2015, EMC, Inc.
    
    'use strict';
    
    var di = require('di'),
    Severity: Major
    Found in lib/services/sku-pack-service.js - About 1 day to fix

      Function registerPack has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          SkuPackService.prototype.registerPack = function(skuId, contents) {
              var promises = [];
              var self = this;
              var skuRoot = self.confRoot + '/' + skuId;
      
      
      Severity: Major
      Found in lib/services/sku-pack-service.js - About 3 hrs to fix

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

            SkuPackService.prototype.installPack = function(fromRoot, skuid) {
                var self = this;
                var contents;
                return fs.readFileAsync(fromRoot + '/config.json')
                .then(function(fileContents) {
        Severity: Major
        Found in lib/services/sku-pack-service.js - About 2 hrs to fix

          Function skuPackHandler has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              SkuPackService.prototype.skuPackHandler = function(req,res,skuid) {
                  var self = this;
                  var name = uuid('v4');
                  var tmpDir = tmp();
          
          
          Severity: Major
          Found in lib/services/sku-pack-service.js - About 2 hrs to fix

            Function skuPackServiceFactory has 16 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                _,
                waterline,
                Logger,
                FileLoader,
                Templates,
            Severity: Major
            Found in lib/services/sku-pack-service.js - About 2 hrs to fix

              Function unregisterPack has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  SkuPackService.prototype.unregisterPack = function(skuid, conf) {
                      var promises = [];
                      var self = this;
                      var skuRoot = self.confRoot + '/' + skuid;
                      var cleanup;
              Severity: Minor
              Found in lib/services/sku-pack-service.js - About 1 hr to fix

                Function skuPackServiceFactory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function skuPackServiceFactory(
                    _,
                    waterline,
                    Logger,
                    FileLoader,
                Severity: Minor
                Found in lib/services/sku-pack-service.js - About 45 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

                            return Promise.try(function() {
                                // Add the static root if it is defined
                                if(conf.httpStaticRoot) {
                                    // directory references are relative to the skuId directory
                                    var httpStaticRoot = skuRoot + path.resolve('/', conf.httpStaticRoot);
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 3 hrs to fix
                lib/services/sku-pack-service.js on lines 308..335

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

                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(conf.httpProfileRoot) {
                                var httpProfileRoot = skuRoot + path.resolve('/', conf.httpProfileRoot);
                                cleanup = fs.readdirAsync(httpProfileRoot).map(function(entry) {
                                    return Profiles.unlink(entry,skuid);
                                });
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 3 hrs to fix
                lib/services/sku-pack-service.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 95.

                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(conf.httpTemplateRoot) {
                                var httpTemplateRoot = skuRoot + path.resolve('/', conf.httpTemplateRoot);
                                cleanup = fs.readdirAsync(httpTemplateRoot).map(function(entry) {
                                    return Templates.unlink(entry,skuid);
                                });
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 3 hrs to fix
                lib/services/sku-pack-service.js on lines 414..420

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

                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 fs.readdirAsync(fromRoot)
                        .filter(function(entry) {
                            return fs.statSync(fromRoot + '/' + entry).isFile();
                        })
                        .map(function(entry) {
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 2 hrs to fix
                lib/services/sku-pack-service.js on lines 631..637

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

                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 fs.readdirAsync(fromRoot)
                        .filter(function(entry) {
                            return fs.statSync(fromRoot + '/' + entry).isFile();
                        })
                        .map(function(entry) {
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 2 hrs to fix
                lib/services/sku-pack-service.js on lines 641..647

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

                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(conf.taskRoot) {
                                var taskRoot = skuRoot + path.resolve('/', conf.taskRoot);
                                cleanup = unloadWorkflowItems(skuid, taskRoot, waterline.taskdefinitions);
                                promises.push(Promise.all(cleanup));
                            }
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 1 hr to fix
                lib/services/sku-pack-service.js on lines 422..426

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

                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(conf.workflowRoot) {
                                var workflowRoot = skuRoot + path.resolve('/', conf.workflowRoot);
                                cleanup = unloadWorkflowItems(skuid, workflowRoot, waterline.graphdefinitions);
                                promises.push(Promise.all(cleanup));
                            }
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 1 hr to fix
                lib/services/sku-pack-service.js on lines 428..432

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

                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

                        _.forEach(obj, function(v) {
                            if (typeof v === "object" && (v = getObjectsWithKey(v, key)).length) {
                                res.push.apply(res, v);
                            }
                        });
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 1 hr to fix
                lib/services/schema-api-service.js on lines 132..136

                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 waterline.skus.create(body).then(function (sku) {
                                return self.regenerateSkus().then(function () {
                                    return sku;
                                });
                            });
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 1 hr to fix
                lib/services/sku-pack-service.js on lines 240..246

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

                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 waterline.skus.destroyByIdentifier(id)
                            .then(function (sku) {
                                return self.regenerateSkus()
                                .then(function() {
                                    return sku;
                Severity: Major
                Found in lib/services/sku-pack-service.js and 1 other location - About 1 hr to fix
                lib/services/sku-pack-service.js on lines 94..98

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

                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