RackHD/on-http

View on GitHub

Showing 440 of 440 total issues

Function schemaApiServiceFactory has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function schemaApiServiceFactory(
    configuration,
    Logger,
    Promise,
    _,
Severity: Major
Found in lib/services/schema-api-service.js - About 3 hrs to fix

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

        Node.prototype.serializeSshSettings = function () {
            var self = this;
    
            if (this.sshSettings) {
                return Promise.resolve().then(function () {
    Severity: Major
    Found in lib/serializables/v1/node.js and 3 other locations - About 3 hrs to fix
    lib/serializables/v1/node.js on lines 106..118
    lib/serializables/v1/node.js on lines 120..132
    lib/serializables/v1/node.js on lines 148..160

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

    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

        Node.prototype.deserializeSnmpSettings = function () {
            var self = this;
    
            if (this.snmpSettings) {
                return Promise.resolve().then(function () {
    Severity: Major
    Found in lib/serializables/v1/node.js and 3 other locations - About 3 hrs to fix
    lib/serializables/v1/node.js on lines 106..118
    lib/serializables/v1/node.js on lines 134..146
    lib/serializables/v1/node.js on lines 148..160

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

    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

        Node.prototype.serializeSnmpSettings = function () {
            var self = this;
    
            if (this.snmpSettings) {
                return Promise.resolve().then(function () {
    Severity: Major
    Found in lib/serializables/v1/node.js and 3 other locations - About 3 hrs to fix
    lib/serializables/v1/node.js on lines 120..132
    lib/serializables/v1/node.js on lines 134..146
    lib/serializables/v1/node.js on lines 148..160

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

    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

        Node.prototype.deserializeSshSettings = function () {
            var self = this;
    
            if (this.sshSettings) {
                return Promise.resolve().then(function () {
    Severity: Major
    Found in lib/serializables/v1/node.js and 3 other locations - About 3 hrs to fix
    lib/serializables/v1/node.js on lines 106..118
    lib/serializables/v1/node.js on lines 120..132
    lib/serializables/v1/node.js on lines 134..146

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

    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 27 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function create(__, ___, injector) {
        injector = injector || require('../../index.js').injector;
        var _ = injector.get('_');
        var swaggerService = injector.get('Http.Services.Swagger');
        var conf = injector.get('Services.Configuration');
    Severity: Minor
    Found in lib/fittings/error_handler.js - About 3 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

    var obmsPut = controller({success: 201}, function(req) {
        var nodeId = req.swagger.params.body.value.nodeId;
        delete req.swagger.params.body.value.nodeId;
        return waterline.obms.upsertByNode(nodeId, req.swagger.params.body.value);
    });
    Severity: Major
    Found in lib/api/2.0/obms.js and 1 other location - About 3 hrs to fix
    lib/api/2.0/ibms.js on lines 21..25

    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

    var ibmsPut = controller({success: 201}, function(req) {
        var nodeId = req.swagger.params.body.value.nodeId;
        delete req.swagger.params.body.value.nodeId;
        return waterline.ibms.upsertByNode(nodeId, req.swagger.params.body.value);
    });
    Severity: Major
    Found in lib/api/2.0/ibms.js and 1 other location - About 3 hrs to fix
    lib/api/2.0/obms.js on lines 36..40

    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

                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

    Function eventCallback has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var eventCallback = function(events) {
        var clients;
        if(_.isArray(events.value)) {
            return _.forEach(events.value, function(event) {
                if(event.reading.sdrType === 'Threshold') {
    Severity: Major
    Found in lib/api/redfish-1.0/event-service.js - About 3 hrs to fix

      Function getManager has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

                if (result.vendor === 'Redfish') {
                    var catalogSource = req.url.replace(req.swagger.params.identifier.value, chassisId).replace(/\/$/, "");
                    return dataFactory(chassisId, catalogSource)
                    .then(function(response) {
                        return response.data;
        Severity: Major
        Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 3 hrs to fix
        lib/api/redfish-1.0/chassis.js on lines 258..337
        lib/api/redfish-1.0/chassis.js on lines 439..506

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

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

                if (result.vendor === 'Redfish') {
                    var catalogSource = req.url.replace(req.swagger.params.identifier.value, chassisId).replace(/\/$/, "");
                    return dataFactory(chassisId, catalogSource)
                    .then(function(response) {
                        return response.data;
        Severity: Major
        Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 3 hrs to fix
        lib/api/redfish-1.0/chassis.js on lines 258..337
        lib/api/redfish-1.0/chassis.js on lines 352..424

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

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

                if (result.vendor === 'Redfish') {
                    var catalogSource = req.url.replace(req.swagger.params.identifier.value, chassisId).replace(/\/$/, "");
                    return dataFactory(chassisId, catalogSource)
                    .then(function(response) {
                        return response.data;
        Severity: Major
        Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 3 hrs to fix
        lib/api/redfish-1.0/chassis.js on lines 352..424
        lib/api/redfish-1.0/chassis.js on lines 439..506

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

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

        function workflowApiServiceFactory(
            eventsProtocol,
            Logger,
            Errors,
            Promise,
        Severity: Major
        Found in lib/services/workflow-api-service.js - About 3 hrs to fix

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

              Node.prototype.serializeObmSettings = function () {
                  var self = this;
                  if (this.obmSettings) {
                      return Promise.map(this.obmSettings, function (item) {
                          var serializable = new ObmSerializable();
          Severity: Major
          Found in lib/serializables/v1/node.js and 1 other location - About 3 hrs to fix
          lib/serializables/v1/node.js on lines 93..104

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

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

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

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

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

          Refactorings

          Further Reading

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

              Node.prototype.deserializeObmSettings = function () {
                  var self = this;
                  if (this.obmSettings) {
                      return Promise.map(this.obmSettings, function (item) {
                          var serializable = new ObmSerializable();
          Severity: Major
          Found in lib/serializables/v1/node.js and 1 other location - About 3 hrs to fix
          lib/serializables/v1/node.js on lines 79..91

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

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

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

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

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

          Refactorings

          Further Reading

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

                                  if (_.includes(fwTypeKeywords, prefix)) {
                                      FWType = prefix + '-' + element["Version"];
                                      entry = {
                                          "Version": element["BIOS Revision"],
                                          "node": source["node"]
          Severity: Major
          Found in lib/api/redfish-1.0/update-service.js and 2 other locations - About 3 hrs to fix
          lib/api/redfish-1.0/update-service.js on lines 368..379
          lib/api/redfish-1.0/update-service.js on lines 383..394

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

          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

                              if (_.includes(fwTypeKeywords, prefix)) {
                                  FWType = prefix + '-' + element["Firmware Version"];
                                  entry = {
                                      "Version": element["Firmware Version"],
                                      "node": source["node"]
          Severity: Major
          Found in lib/api/redfish-1.0/update-service.js and 2 other locations - About 3 hrs to fix
          lib/api/redfish-1.0/update-service.js on lines 352..363
          lib/api/redfish-1.0/update-service.js on lines 368..379

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

          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

                              if (_.includes(fwTypeKeywords, prefix)) {
                                  FWType = prefix + '-' + element["Firmware Revision"];
                                  entry = {
                                      "Version": element["Firmware Revision"],
                                      "node": source["node"]
          Severity: Major
          Found in lib/api/redfish-1.0/update-service.js and 2 other locations - About 3 hrs to fix
          lib/api/redfish-1.0/update-service.js on lines 352..363
          lib/api/redfish-1.0/update-service.js on lines 383..394

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

          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