RackHD/on-tasks

View on GitHub
lib/jobs/snmp-job.js

Summary

Maintainability
F
1 wk
Test Coverage

Function snmpJobFactory has 305 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function snmpJobFactory(
    BaseJob,
    SnmpTool,
    Constants,
    Logger,
Severity: Major
Found in lib/jobs/snmp-job.js - About 1 day to fix

    Function snmpJobFactory has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

    function snmpJobFactory(
        BaseJob,
        SnmpTool,
        Constants,
        Logger,
    Severity: Minor
    Found in lib/jobs/snmp-job.js - About 1 day 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 snmp-job.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2015, EMC, Inc.
    
    'use strict';
    
    var di = require('di');
    Severity: Minor
    Found in lib/jobs/snmp-job.js - About 4 hrs to fix

      Function _determineAlert has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          SnmpJob.prototype._determineAlert = function _determineAlert(data, previous) {
              var self = this;
              var alerts = _.reduce( _.merge({}, _.get(self.skuSnmpConfig, 'alerts', {}), data.config.alerts),
                  function(result, val) {
                      _.keys(val).forEach(function(key) {
      Severity: Major
      Found in lib/jobs/snmp-job.js - About 3 hrs to fix

        Function _snmpCommandCallback has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            SnmpJob.prototype._snmpCommandCallback = function(data) {
                var self = this;
        
                if (self.concurrentRequests(data.host, data.workItemId)) {
                    return;
        Severity: Major
        Found in lib/jobs/snmp-job.js - About 3 hrs to fix

          Function _collectMetricData has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              SnmpJob.prototype._collectMetricData = function(data) {
                  var self = this;
                  assert.object(data);
                  assert.object(data.config);
                  assert.string(data.config.metric);
          Severity: Major
          Found in lib/jobs/snmp-job.js - About 2 hrs to fix

            Function snmpJobFactory has 14 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                BaseJob,
                SnmpTool,
                Constants,
                Logger,
                util,
            Severity: Major
            Found in lib/jobs/snmp-job.js - About 1 hr to fix

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

                  SnmpJob.prototype.concurrentRequests = function(host, workItemId) {
                      assert.string(host);
                      assert.string(workItemId);
                      if(!_.has(this.concurrent, host)){
                          this.concurrent[host] = {};
              Severity: Major
              Found in lib/jobs/snmp-job.js and 1 other location - About 6 hrs to fix
              lib/jobs/redfish-job.js on lines 133..147

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

              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.workitems.findOne({ id: data.workItemId})
                          .then(function(workitem) {
                              return pollerHelper.getNodeAlertMsg(workitem.node, workitem.state, "inaccessible")
                              .tap(function(message){
                                  return waterline.workitems.setFailed(null, message, workitem);
              Severity: Major
              Found in lib/jobs/snmp-job.js and 1 other location - About 2 hrs to fix
              lib/jobs/ipmi-job.js on lines 166..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

                  SnmpJob.prototype.addConcurrentRequest = function(host, workItemId) {
                      assert.number(this.concurrent[host][workItemId]);
                      this.concurrent[host][workItemId] += 1;
                  };
              Severity: Major
              Found in lib/jobs/snmp-job.js and 1 other location - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 83..86

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 64.

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

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

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

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

              Refactorings

              Further Reading

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

                  SnmpJob.prototype.removeConcurrentRequest = function(host, workItemId) {
                      assert.number(this.concurrent[host][workItemId]);
                      this.concurrent[host][workItemId] -= 1;
                  };
              Severity: Major
              Found in lib/jobs/snmp-job.js and 1 other location - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 78..81

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 64.

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

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

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

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

              Refactorings

              Further Reading

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpMemoryUsage:
                              Metric = injector.get('JobUtils.Metrics.Snmp.MemoryUsageMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 224..227
              lib/jobs/snmp-job.js on lines 228..231

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpProcessorLoad:
                              Metric = injector.get('JobUtils.Metrics.Snmp.ProcessorLoadMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 224..227
              lib/jobs/snmp-job.js on lines 228..231

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpPduPowerStatus:
                              Metric = injector.get('JobUtils.Metrics.Snmp.PduPowerMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 224..227
              lib/jobs/snmp-job.js on lines 228..231

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpInterfaceState:
                              Metric = injector.get('JobUtils.Metrics.Snmp.InterfaceStateMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 224..227
              lib/jobs/snmp-job.js on lines 228..231

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpTxRxCounters:
                              Metric = injector.get('JobUtils.Metrics.Snmp.TxRxCountersMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 228..231

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpSwitchSensorStatus:
                              Metric = injector.get('JobUtils.Metrics.Snmp.SwitchSensorMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 220..223
              lib/jobs/snmp-job.js on lines 224..227

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

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

                          case Constants.WorkItems.Pollers.Metrics.SnmpPduSensorStatus:
                              Metric = injector.get('JobUtils.Metrics.Snmp.PduSensorMetric');
                              metric = new Metric(data.node, data.host, data.community);
                              break;
              Severity: Major
              Found in lib/jobs/snmp-job.js and 6 other locations - About 1 hr to fix
              lib/jobs/snmp-job.js on lines 204..207
              lib/jobs/snmp-job.js on lines 208..211
              lib/jobs/snmp-job.js on lines 212..215
              lib/jobs/snmp-job.js on lines 216..219
              lib/jobs/snmp-job.js on lines 224..227
              lib/jobs/snmp-job.js on lines 228..231

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

              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

                          currentData = _.reduce(data.result, function(result, obj) {
                              _.forEach(obj.values, function(val, key) {
                                  result[key] = val;
                              });
                              return result;
              Severity: Minor
              Found in lib/jobs/snmp-job.js and 1 other location - About 30 mins to fix
              lib/jobs/snmp-job.js on lines 126..131

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

              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

                                  _.set(self.resultCache, keyName, _.reduce(result, function(res, obj) {
                                      _.forEach(obj.values, function(val, key) {
                                          res[key] = val;
                                      });
                                      return res;
              Severity: Minor
              Found in lib/jobs/snmp-job.js and 1 other location - About 30 mins to fix
              lib/jobs/snmp-job.js on lines 337..342

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

              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