RackHD/on-http

View on GitHub

Showing 440 of 440 total issues

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

                _.forEach(smart.data, function (ele) {
                    if (typeof ele.Controller.controller_PCI_BDF !== 'undefined') {
                        var id = ele.Controller.controller_PCI_BDF.replace(/[:.]/g, '_');
                        if (!(id in controllers)) {
                            controllers[id] = [];
Severity: Major
Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 3 hrs to fix
lib/api/redfish-1.0/systems.js on lines 945..953
lib/api/redfish-1.0/systems.js on lines 1112..1120

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

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(smart.data, function (ele) {
                    if (typeof ele.Controller.controller_PCI_BDF !== 'undefined') {
                        var id = ele.Controller.controller_PCI_BDF.replace(/[:.]/g, '_');
                        if (!(id in controllers)) {
                            controllers[id] = [];
Severity: Major
Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 3 hrs to fix
lib/api/redfish-1.0/systems.js on lines 945..953
lib/api/redfish-1.0/systems.js on lines 1021..1029

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

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(smart.data, function(ele) {
                        if (typeof ele.Controller.controller_PCI_BDF !== 'undefined') {
                            var id = ele.Controller.controller_PCI_BDF.replace(/[:.]/g, '_');
                            if(!(id in controllers)) {
                                controllers[id] = [];
Severity: Major
Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 3 hrs to fix
lib/api/redfish-1.0/systems.js on lines 1021..1029
lib/api/redfish-1.0/systems.js on lines 1112..1120

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

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

        case 'selInfoData':
            return nodeApi.getPollersByNodeId(identifier)
            .filter(function(poller) {
                return poller.config.command === 'selInformation';
            }).spread(function(poller) {
Severity: Major
Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 3 hrs to fix
lib/api/redfish-1.0/chassis.js on lines 144..152
lib/api/redfish-1.0/systems.js on lines 64..72

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

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.try(function() {
                if(identifier === reservedId){
                    throw new Errors.NotFoundError();
                }
                return waterline.nodes.getNodeById(identifier);
Severity: Major
Found in lib/api/redfish-1.0/managers.js and 1 other location - About 3 hrs to fix
lib/api/redfish-1.0/managers.js on lines 489..521

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

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.try(function () {
                if(identifier === reservedId){
                    throw new Errors.NotFoundError();
                }
                return waterline.nodes.getNodeById(identifier);
Severity: Major
Found in lib/api/redfish-1.0/managers.js and 1 other location - About 3 hrs to fix
lib/api/redfish-1.0/managers.js on lines 440..463

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

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

        case 'selData':
            return nodeApi.getPollersByNodeId(identifier)
            .filter(function(poller) {
                return poller.config.command === 'sel';
            }).spread(function(poller) {
Severity: Major
Found in lib/api/redfish-1.0/systems.js and 2 other locations - About 3 hrs to fix
lib/api/redfish-1.0/chassis.js on lines 144..152
lib/api/redfish-1.0/systems.js on lines 55..63

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

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

        case 'sdrData':
            return nodeApi.getPollersByNodeId(identifier)
            .filter(function(poller) {
                return poller.config.command === 'sdr';
            }).spread(function(poller) {
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/systems.js on lines 55..63
lib/api/redfish-1.0/systems.js on lines 64..72

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

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

function getFwCollections(fwTypeKeywords, catalogs) {
    //Return a collection of the unique FW versions and its related components
    var fwTypes = {};
    _.forEach(catalogs, function (catalog) {
        _.forEach(catalog, function (sources) {
Severity: Major
Found in lib/api/redfish-1.0/update-service.js - About 3 hrs to fix

    Function authServiceFactory has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function authServiceFactory(
        assert,
        configuration,
        _,
        waterline
    Severity: Minor
    Found in lib/services/auth-service.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

    Function getSimpleStorage has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var getSimpleStorage = controller(function(req, res)  {
        var identifier = req.swagger.params.identifier.value;
        var index = req.swagger.params.index.value;
    
        return redfish.getVendorNameById(identifier)
    Severity: Major
    Found in lib/api/redfish-1.0/systems.js - About 3 hrs to fix

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

      var getThermal = controller(function(req, res) {
          var chassisId = req.swagger.params.identifier.value.split('.')[0];
          var systemId = req.swagger.params.identifier.value.split('.')[1];
      
          return redfish.getVendorNameById(chassisId)
      Severity: Major
      Found in lib/api/redfish-1.0/chassis.js - About 3 hrs 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 create has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function create(fittingDef) {
              var validate = validator();
              return function swagger_validator(context, next) {    // jshint ignore:line
                  if (!context.response.headersSent) {
                      var schemaNameKey = fittingDef.schemaNameKey;
          Severity: Minor
          Found in lib/fittings/rackhd_validator.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

          Function getStorage has 80 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var getStorage = controller(function (req, res) {
              var identifier = req.swagger.params.identifier.value;
              var index = req.swagger.params.index.value;
          
              return redfish.getVendorNameById(identifier)
          Severity: Major
          Found in lib/api/redfish-1.0/systems.js - About 3 hrs to fix

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

            var getSoftwareInventoryById = controller({success: 200}, function (req, res) {
                var identifier = req.swagger.params.identifier.value;
                var options = redfish.makeOptions(req, res, identifier);
                var matchComponent = "APAC";
                var keyMatch = Object.keys(swPathsLookups);
            Severity: Major
            Found in lib/api/redfish-1.0/update-service.js and 1 other location - About 3 hrs to fix
            lib/api/redfish-1.0/update-service.js on lines 249..255

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

            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 getFirmwareInventoryById = controller({success: 200}, function (req, res) {
                var identifier = req.swagger.params.identifier.value;
                var options = redfish.makeOptions(req, res, identifier);
                var matchComponent = "FRMW";
                var keyMatch = Object.keys(fwPathsLookups);
            Severity: Major
            Found in lib/api/redfish-1.0/update-service.js and 1 other location - About 3 hrs to fix
            lib/api/redfish-1.0/update-service.js on lines 257..263

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

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

            var getPower = controller(function(req, res) {
                var chassisId = req.swagger.params.identifier.value.split('.')[0];
                var systemId = req.swagger.params.identifier.value.split('.')[1];
            
                return redfish.getVendorNameById(chassisId)
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js - About 3 hrs to fix

              Function UPnPServiceFactory has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

              function UPnPServiceFactory(
                  _,
                  waterline,
                  Logger,
                  Profiles,
              Severity: Minor
              Found in lib/services/upnp-service.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

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

              // Copyright © 2016-2017 Dell Inc. or its subsidiaries.  All Rights Reserved.
              
              'use strict';
              
              var di = require('di');
              Severity: Minor
              Found in lib/services/notification-api-service.js - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language