RackHD/on-http

View on GitHub

Showing 440 of 440 total issues

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

File event-service.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright 2016, EMC, Inc.

'use strict';
var urlParse = require('url-parse');
var injector = require('../../../index.js').injector;
Severity: Minor
Found in lib/api/redfish-1.0/event-service.js - About 3 hrs to fix

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

                    _.forEach(hardware.data.storage.controllers, function (ele) {
                        var id = ele.fQDD.replace(/[:.]/g, '_');  // jshint ignore: line
                        if (!(id in controllers)) {
                            controllers[id] = [];
                        }
    Severity: Major
    Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 2 hrs to fix
    lib/api/redfish-1.0/systems.js on lines 893..899
    lib/api/redfish-1.0/systems.js on lines 1069..1075

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

    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

                    _.forEach(hardware.data.storage.controllers, function (ele) {
                        var id = ele.fQDD.replace(/[:.]/g, '_'); // jshint ignore: line
                        if (!(id in controllers)) {
                            controllers[id] = [];
                        }
    Severity: Major
    Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 2 hrs to fix
    lib/api/redfish-1.0/systems.js on lines 893..899
    lib/api/redfish-1.0/systems.js on lines 990..996

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

    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

                    _.forEach(hardware.data.storage.controllers, function(ele) {
                        var id = ele.fQDD.replace(/[:.]/g, '_'); // jshint ignore: line
                        if(!(id in controllers)) {
                            controllers[id] = [];
                        }
    Severity: Major
    Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 2 hrs to fix
    lib/api/redfish-1.0/systems.js on lines 990..996
    lib/api/redfish-1.0/systems.js on lines 1069..1075

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function create(fittingDef, bagpipes) {
        var swaggerNodeRunner = bagpipes.config.swaggerNodeRunner;
        var appRoot = swaggerNodeRunner.config.swagger.appRoot;
        var serdesDirs = fittingDef.serdesDirs.map(function(dir) {
            return path.resolve(appRoot, dir);
    Severity: Minor
    Found in lib/fittings/swagger_serdes.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

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

                        obm: Promise.resolve(node)
                            .then(function(node) {
                                return _.map(node.obms, function(val, idx) {
                                    return node.id + '.' + idx;
                                });
    Severity: Major
    Found in lib/api/redfish-1.0/networks.js and 1 other location - About 2 hrs to fix
    lib/api/redfish-1.0/networks.js on lines 76..85

    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

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

                        obm: Promise.resolve(node)
                            .then(function(node) {
                                return _.map(node.obms, function(val, idx) {
                                    return node.id + '.' + idx;
                                });
    Severity: Major
    Found in lib/api/redfish-1.0/networks.js and 1 other location - About 2 hrs to fix
    lib/api/redfish-1.0/networks.js on lines 52..61

    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

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

    var listManagerNetworkProtocol = controller(function(req, res) {
        var identifier = req.swagger.params.identifier.value;
        var options = redfish.makeOptions(req, res, identifier);
    
        return redfish.getVendorNameById(identifier)
    Severity: Major
    Found in lib/api/redfish-1.0/managers.js - About 2 hrs to fix

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

      function SshFactory (Promise, Serializable, encryption) {
      
          function Ssh (defaults) {
              Serializable.call(this, Ssh.schema, defaults);
          }
      Severity: Major
      Found in lib/serializables/v1/ssh.js - About 2 hrs to fix

        Function doReset has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var doReset = controller(function(req,res) {
            //TODO Fix for node types
            var identifier = req.swagger.params.identifier.value;
            var payload = req.swagger.params.payload.value;
            var options;
        Severity: Major
        Found in lib/api/redfish-1.0/systems.js - About 2 hrs to fix

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

              Node.prototype.deserialize = function (target) {
                  var self = this;
          
                  this.defaults(target);
                  return Promise.all([
          Severity: Major
          Found in lib/serializables/v1/node.js and 1 other location - About 2 hrs to fix
          lib/serializables/v1/node.js on lines 162..173

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

          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

              Node.prototype.serialize = function (target) {
                  var self = this;
                  this.defaults(target);
                  return Promise.all([
                          this.serializeSnmpSettings(),
          Severity: Major
          Found in lib/serializables/v1/node.js and 1 other location - About 2 hrs to fix
          lib/serializables/v1/node.js on lines 175..187

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function schemaApiServiceFactory has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function schemaApiServiceFactory(
              configuration,
              Logger,
              Promise,
              _,
          Severity: Minor
          Found in lib/services/schema-api-service.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

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

              NodeApiService.prototype.postNodeSshById = function(id, ibm) {
                  return waterline.nodes.getNodeById(id)
                      .then(function (node) {
                          if (!node) {
                              throw new Errors.NotFoundError(
          Severity: Major
          Found in lib/services/nodes-api-service.js and 1 other location - About 2 hrs to fix
          lib/services/nodes-api-service.js on lines 739..749

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

          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

              NodeApiService.prototype.putObmsByNodeId = function(id, obm) {
                  return waterline.nodes.getNodeById(id)
                      .then(function (node) {
                          if (!node) {
                              throw new Errors.NotFoundError(
          Severity: Major
          Found in lib/services/nodes-api-service.js and 1 other location - About 2 hrs to fix
          lib/services/nodes-api-service.js on lines 498..508

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

          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

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

                function httpEventMiddleware(req, res, next) {
                    req._startAt = process.hrtime();
                    res.locals.ipAddress = remoteAddress(req);
                    res.locals.scope = ['global'];
                    res.locals.uuid = uuid.v4();
            Severity: Major
            Found in lib/services/http-service.js - About 2 hrs to fix

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

              var schemasIdGet = controller(function(req) {
                  var schemaUid = nameSpace + req.swagger.params.identifier.value;
                  var schema = schemaApiService.getSchema(schemaUid);
                  if (schema) {
                      return schema;
              Severity: Major
              Found in lib/api/2.0/schemas2.js and 1 other location - About 2 hrs to fix
              lib/api/2.0/obms.js on lines 21..28

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

              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

              Severity
              Category
              Status
              Source
              Language