asa-git/forked-worker-pool

View on GitHub

Showing 7 of 7 total issues

Function filterConfig has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function filterConfig(config) {

    // check the required parameters
    if (!isStrictObject(config))                    { throw new TypeError('Expecting a valid config object'); }
    if (!isNonEmptyString(config.path))                { throw new Error('Expecting a path for the workers module'); }
Severity: Minor
Found in lib/index.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 start has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Pool.prototype.start = function() {
    var self = this;
    function removeJob(worker, wasSuccessfull) {
        var job = removeFromArray(self._jobs.assigned, function(job) { return (job.worker===worker); });
        removeFromArray(self._workers.busy, worker);
Severity: Major
Found in lib/index.js - About 2 hrs to fix

    Function createWorker has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function createWorker(config) {
            return new _ForkedWorker(config)
                    .on('started', function(worker) {
                        if (self._hasWorker(worker)) {
                            self._workers.idle.push(worker);
    Severity: Minor
    Found in lib/index.js - About 1 hr to fix

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

      function _ForkedWorker(config) {
      
          if (!(this instanceof _ForkedWorker)) {
              return new _ForkedWorker(config);
          }
      Severity: Minor
      Found in lib/_ForkedWorker.js - About 1 hr to fix

        Function ForkedWorker has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function ForkedWorker() {
            if (!(this instanceof ForkedWorker)) {
                return new ForkedWorker();
            }
            var self = this;
        Severity: Minor
        Found in lib/ForkedWorker.js - About 1 hr to fix

          Function _ForkedWorker has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function _ForkedWorker(config) {
          
              if (!(this instanceof _ForkedWorker)) {
                  return new _ForkedWorker(config);
              }
          Severity: Minor
          Found in lib/_ForkedWorker.js - About 35 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

          Function start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          Pool.prototype.start = function() {
              var self = this;
              function removeJob(worker, wasSuccessfull) {
                  var job = removeFromArray(self._jobs.assigned, function(job) { return (job.worker===worker); });
                  removeFromArray(self._workers.busy, worker);
          Severity: Minor
          Found in lib/index.js - About 35 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

          Severity
          Category
          Status
          Source
          Language