RackHD/on-http

View on GitHub
lib/api/redfish-1.0/chassis.js

Summary

Maintainability
F
1 wk
Test Coverage

File chassis.js has 486 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright 2016, EMC, Inc.

'use strict';

var injector = require('../../../index.js').injector;
Severity: Minor
Found in lib/api/redfish-1.0/chassis.js - About 7 hrs to fix

    Function dataFactory has 154 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var dataFactory = function(identifier, dataName) {
        switch(dataName)  {
            case 'catData':
                return nodeApi.getNodeCatalogSourceById(identifier, 'ohai')
                    .then(function(catalog) {
    Severity: Major
    Found in lib/api/redfish-1.0/chassis.js - About 6 hrs to fix

      Function getChassis has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var getChassis = controller(function(req, res) {
          var chassisId = req.swagger.params.identifier.value.split('.')[0];
          var systemId = req.swagger.params.identifier.value.split('.')[1];
          var typeEnum = [
              "Rack",
      Severity: Major
      Found in lib/api/redfish-1.0/chassis.js - About 4 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 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

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

                    } else if (result.vendor === 'Cisco') {
                        return dataFactory(chassisId, 'ucsThermal')
                        .then(function(thermalData) {
                            var ucsPowerThermalData = thermalData['ucs.powerthermal'];
                            var ucsFanData = thermalData['ucs.fan'];
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 day to fix
            lib/api/redfish-1.0/chassis.js on lines 448..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 333.

            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

                    } else if (result.vendor === 'Cisco') {
                        return dataFactory(chassisId, 'ucsPower')
                        .then(function(powerData) {
                            var ucsPowerThermalData = powerData['ucs.powerthermal'];
                            var ucsPsuData = powerData['ucs.psu'];
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 day to fix
            lib/api/redfish-1.0/chassis.js on lines 361..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 333.

            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

                    case 'ucsThermal':
                        var ucsThermalPollerData = {};
                        var ucsThermalKeyMap = {
                            'ucs.powerthermal': 'computeMbTempStats',
                            'ucs.fan': 'equipmentFanStats'
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 day to fix
            lib/api/redfish-1.0/chassis.js on lines 175..195

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

            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

                    case 'ucsPower':
                        var ucsPowerPollerData = {};
                        var ucsPowerKeyMap = {
                            'ucs.powerthermal': 'computeMbPowerStats',
                            'ucs.psu': 'equipmentPsuStats'
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 day to fix
            lib/api/redfish-1.0/chassis.js on lines 153..174

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

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

            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

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

                    case 'system':
                        return nodeApi.getNodeById(identifier)
                        .then(function(node) {
                            return _.filter(node.relations, function(relation) {
                                return relation.relationType === 'encloses';
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 2 hrs to fix
            lib/api/redfish-1.0/systems.js on lines 30..38

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

            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

                            ucsPsuData.map(function(item) {
                                options.wattsList.push(
                                    {
                                        'sensorId': item.dn.split('/').slice(0, -1).join('/'),
                                        'sensorReading': item.psu_wattage
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 2 hrs to fix
            lib/api/redfish-1.0/chassis.js on lines 380..387
            lib/api/redfish-1.0/chassis.js on lines 455..462

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

            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

                            ucsPowerThermalData.map(function(item) {
                                options.voltageList.push(
                                    {
                                        'sensorId': item.dn.split('/').slice(0, -1).join('/'),
                                        'sensorReading': item.input_voltage
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 2 hrs to fix
            lib/api/redfish-1.0/chassis.js on lines 380..387
            lib/api/redfish-1.0/chassis.js on lines 463..470

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

            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

                            ucsFanData.map(function (item) {
                                options.fanList.push(
                                    {
                                        'sensorId': item.dn.split('/').slice(0, -1).join('/'),
                                        'sensorReading': item.speed
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 2 other locations - About 2 hrs to fix
            lib/api/redfish-1.0/chassis.js on lines 455..462
            lib/api/redfish-1.0/chassis.js on lines 463..470

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

            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 waterline.nodes.findByIdentifier(objId)
                        .then(function(obj) {
                            return env.get('config.redfish.computeType', 'Other', obj && obj.sku ? [ obj.sku ] : null );
                        })
                        .then(function(val) {
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 hr to fix
            lib/api/redfish-1.0/chassis.js on lines 275..285

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

            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 waterline.nodes.findByIdentifier(objId)
                                            .then(function (obj) {
                                                return env.get('config.redfish.computeType', 'Other', obj && obj.sku ? [obj.sku] : null);
                                            })
                                            .then(function (val) {
            Severity: Major
            Found in lib/api/redfish-1.0/chassis.js and 1 other location - About 1 hr to fix
            lib/api/redfish-1.0/chassis.js on lines 210..219

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

            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