Strider-CD/strider

View on GitHub
modules/strider-runner-core/lib/job.js

Summary

Maintainability
D
2 days
Test Coverage

File job.js has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var _ = require('lodash');
var async = require('async');
var colorize = require('./colorize');
Severity: Minor
Found in modules/strider-runner-core/lib/job.js - About 5 hrs to fix

    Function cmd has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      cmd: function (cmd, plugin, next) {
        if (arguments.length === 2) {
          next = plugin;
          plugin = null;
        }
    Severity: Major
    Found in modules/strider-runner-core/lib/job.js - About 3 hrs to fix

      Function phaseDone has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        phaseDone: function (next, started, err, actuallyRan) {
          /* jshint maxcomplexity: 11 */
          var code = 0;
          var now = new Date();
      
      
      Severity: Minor
      Found in modules/strider-runner-core/lib/job.js - About 2 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 pluginContext has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        pluginContext: function (pluginName, env, path) {
          var self = this;
          var context = {
            status: this.status.bind(this),
            out: this.out.bind(this),
      Severity: Major
      Found in modules/strider-runner-core/lib/job.js - About 2 hrs to fix

        Function phaseDone has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          phaseDone: function (next, started, err, actuallyRan) {
            /* jshint maxcomplexity: 11 */
            var code = 0;
            var now = new Date();
        
        
        Severity: Minor
        Found in modules/strider-runner-core/lib/job.js - About 1 hr to fix

          Function runPhase has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            runPhase: function (next) {
              if (this.cancelled) return;
          
              debug('Running phase', this.phase);
          
          
          Severity: Minor
          Found in modules/strider-runner-core/lib/job.js - About 1 hr to fix

            Function Job has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function Job(job, provider, plugins, config) {
              var jobId = job._id.toString();
            
              debug(
                `Creating new job "${jobId}" for project "${job.project.display_name}" using provider "${provider.id}".`
            Severity: Minor
            Found in modules/strider-runner-core/lib/job.js - About 1 hr to fix

              Function run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                run: function (done) {
                  debug(`Running job "${this.id}"...`);
              
                  var self = this;
                  var dom = require('domain').create();
              Severity: Minor
              Found in modules/strider-runner-core/lib/job.js - About 1 hr to fix

                Function getPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function getPath(path) {
                  var envPath = process.env.path || process.env.Path || process.env.PATH;
                
                  if (path) {
                    var sep = process.platform === 'win32' ? ';' : ':';
                Severity: Minor
                Found in modules/strider-runner-core/lib/job.js - About 25 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                          for (var i = 0; i < self.commands.length; i++) {
                            if (self.commands[i].proc === proc) {
                              ind = i;
                              break;
                            }
                Severity: Major
                Found in modules/strider-runner-core/lib/job.js and 1 other location - About 1 hr to fix
                clients/classic-ui/client/job-status/controllers/job.js on lines 306..311

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

                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

                        proc.stderr.on('data', function (buf) {
                          if (!options.silent) {
                            self.status('stderr', buf);
                          }
                
                
                Severity: Major
                Found in modules/strider-runner-core/lib/job.js and 1 other location - About 1 hr to fix
                modules/strider-runner-core/lib/job.js on lines 243..249

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

                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

                        proc.stdout.on('data', function (buf) {
                          if (!options.silent) {
                            self.status('stdout', buf);
                          }
                
                
                Severity: Major
                Found in modules/strider-runner-core/lib/job.js and 1 other location - About 1 hr to fix
                modules/strider-runner-core/lib/job.js on lines 251..257

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

                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