RackHD/on-taskgraph

View on GitHub
lib/task-scheduler.js

Summary

Maintainability
F
6 days
Test Coverage

Function taskSchedulerFactory has 456 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function taskSchedulerFactory(
    eventsProtocol,
    store,
    LeaseExpirationPoller,
    Constants,
Severity: Major
Found in lib/task-scheduler.js - About 2 days to fix

    File task-scheduler.js has 497 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/task-scheduler.js - About 7 hrs to fix

      Function taskSchedulerFactory has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

      function taskSchedulerFactory(
          eventsProtocol,
          store,
          LeaseExpirationPoller,
          Constants,
      Severity: Minor
      Found in lib/task-scheduler.js - About 4 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 taskSchedulerFactory has 15 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          eventsProtocol,
          store,
          LeaseExpirationPoller,
          Constants,
          Logger,
      Severity: Major
      Found in lib/task-scheduler.js - About 1 hr to fix

        Function start has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            TaskScheduler.prototype.start = function() {
                var self = this;
                return Promise.resolve()
                .then(function() {
                    self.running = true;
        Severity: Minor
        Found in lib/task-scheduler.js - About 1 hr to fix

          Function failGraph has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              TaskScheduler.prototype.failGraph = function(data, graphState) {
                  var self = this;
                  var graphToBePublished;
                  return Rx.Observable.just(data.graphId)
                  .flatMap(store.getActiveGraphById)
          Severity: Minor
          Found in lib/task-scheduler.js - About 1 hr to fix

            Function subscribeCancelGraph has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                TaskScheduler.prototype.subscribeCancelGraph = function() {
                    var self = this;
                    return taskMessenger.subscribeCancelGraph(
                        function(data) {
                            var resolve;
            Severity: Minor
            Found in lib/task-scheduler.js - About 1 hr to fix

              Function initializePipeline has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  TaskScheduler.prototype.initializePipeline = function() {
                      /*
                       * Before setting up the stream, make sure it is running, otherwise
                       * this will create a stream that will never run and immediately complete.
                       * This is basically defensive programming to try to prevent accidents where the
              Severity: Minor
              Found in lib/task-scheduler.js - About 1 hr to fix

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

                    TaskScheduler.prototype._publishGraphFinished = function(graph) {
                        return eventsProtocol.publishGraphFinished(graph.instanceId, {
                            graphId: graph.instanceId,
                            graphName: graph.name,
                            status: graph._status
                Severity: Major
                Found in lib/task-scheduler.js and 1 other location - About 4 hrs to fix
                lib/completed-task-poller.js on lines 307..320

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

                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

                    TaskScheduler.prototype.handleStreamError = function(msg, err) {
                        logger.error(msg, {
                            schedulerId: this.schedulerId,
                            // stacks on some error objects (particularly from the assert library)
                            // don't get printed if part of the error object so separate them out here.
                Severity: Major
                Found in lib/task-scheduler.js and 2 other locations - About 2 hrs to fix
                lib/lease-expiration-poller.js on lines 113..122
                lib/task-runner.js on lines 313..322

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 88.

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

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

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

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

                Refactorings

                Further Reading

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

                        return Rx.Observable.interval(self.pollInterval)
                        .takeWhile(self.isRunning.bind(self))
                        .map(self.findUnevaluatedTasks.bind(self, self.domain))
                        .mergeLossy(self.concurrencyMaximums.findUnevaluatedTasks)
                Severity: Major
                Found in lib/task-scheduler.js and 1 other location - About 1 hr to fix
                lib/completed-task-poller.js on lines 92..95

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

                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

                        this.createUnevaluatedTaskPollerSubscription(this.evaluateTaskStream)
                        .subscribe(
                            this.handleStreamDebug.bind(this, 'Triggered evaluate task event'),
                            this.handleStreamError.bind(this, 'Error polling for tasks')
                        );
                Severity: Major
                Found in lib/task-scheduler.js and 2 other locations - About 55 mins to fix
                lib/task-scheduler.js on lines 179..183
                lib/task-scheduler.js on lines 185..189

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

                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

                        this.createTasksToScheduleSubscription(this.evaluateGraphStream)
                        .subscribe(
                            this.handleStreamSuccess.bind(this, 'Task scheduled'),
                            this.handleStreamError.bind(this, 'Error at task scheduling stream')
                        );
                Severity: Major
                Found in lib/task-scheduler.js and 2 other locations - About 55 mins to fix
                lib/task-scheduler.js on lines 173..177
                lib/task-scheduler.js on lines 179..183

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

                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

                        this.createEvaluatedTaskPollerSubscription(this.evaluateGraphStream)
                        .subscribe(
                            this.handleStreamDebug.bind(this, 'Triggered evaluate graph event'),
                            this.handleStreamError.bind(this, 'Error polling for tasks')
                        );
                Severity: Major
                Found in lib/task-scheduler.js and 2 other locations - About 55 mins to fix
                lib/task-scheduler.js on lines 173..177
                lib/task-scheduler.js on lines 185..189

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

                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