h2non/thread.js

View on GitHub

Showing 24 of 140 total issues

Function worker has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring.
Open

function worker() {
  var self = this

  function $$evalExpr(expr) {
    var fn = null
Severity: Minor
Found in lib/worker.js - About 2 days 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 thread.js has 876 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! thread.js - v0.1.16 - MIT License - https://github.com/h2non/thread.js */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.thread=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var _ = require('./utils')
var workerSrc = require('./worker')

Severity: Major
Found in thread.js - About 2 days to fix

    Function 8 has 245 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    },{}],8:[function(require,module,exports){
    module.exports = worker
    
    function worker() {
      var self = this
    Severity: Major
    Found in thread.js - About 1 day to fix

      Function worker has 242 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function worker() {
        var self = this
      
        function $$evalExpr(expr) {
          var fn = null
      Severity: Major
      Found in thread.js - About 1 day to fix

        Function worker has 242 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function worker() {
          var self = this
        
          function $$evalExpr(expr) {
            var fn = null
        Severity: Major
        Found in lib/worker.js - About 1 day to fix

          Function isolated has 233 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            (function isolated() {
              'use strict'
          
              var namespace = 'env'
              var isWorker = typeof document === 'undefined'
          Severity: Major
          Found in lib/worker.js - About 1 day to fix

            Function isolated has 233 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              (function isolated() {
                'use strict'
            
                var namespace = 'env'
                var isWorker = typeof document === 'undefined'
            Severity: Major
            Found in thread.js - About 1 day to fix

              Function 6 has 174 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              },{"./utils":7}],6:[function(require,module,exports){
              var _ = require('./utils')
              var workerSrc = require('./worker')
              var Task = require('./task')
              var FakeWorker = require('./fake-worker')
              Severity: Major
              Found in thread.js - About 6 hrs to fix

                Function 5 has 163 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                },{"./utils":7}],5:[function(require,module,exports){
                var _ = require('./utils')
                
                module.exports = Task
                
                
                Severity: Major
                Found in thread.js - About 6 hrs to fix

                  Function 1 has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.thread=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
                  var _ = require('./utils')
                  var workerSrc = require('./worker')
                  
                  var eventMethod = window.addEventListener ? 'addEventListener' : 'attachEvent'
                  Severity: Major
                  Found in thread.js - About 3 hrs to fix

                    Function 7 has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    },{"./fake-worker":1,"./pool":3,"./store":4,"./task":5,"./utils":7,"./worker":8}],7:[function(require,module,exports){
                    var _ = exports
                    var toStr = Object.prototype.toString
                    var slice = Array.prototype.slice
                    var hasOwn = Object.prototype.hasOwnProperty
                    Severity: Major
                    Found in thread.js - About 2 hrs to fix

                      Function 3 has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      },{"./store":4,"./thread":6}],3:[function(require,module,exports){
                      var _ = require('./utils')
                      
                      module.exports = threadPool
                      
                      
                      Severity: Major
                      Found in thread.js - About 2 hrs to fix

                        Function exports has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function(config) {
                          var customLaunchers = {
                            sl_chrome: {
                              base: 'SauceLabs',
                              browserName: 'chrome',
                        Severity: Minor
                        Found in karma.conf.js - About 1 hr to fix

                          Function 4 has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          },{"./utils":7}],4:[function(require,module,exports){
                          var _ = require('./utils')
                          
                          var buf = []
                          var store = module.exports = {}
                          Severity: Minor
                          Found in thread.js - About 1 hr to fix

                            Function each has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            exports.each = function (obj, fn) {
                              var i, l
                              if (_.isArr(obj))
                                for (i = 0, l = obj.length; i < l; i += 1) fn(obj[i], i)
                              else if (_.isObj(obj))
                            Severity: Minor
                            Found in lib/utils.js - About 55 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 dispatcher has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function dispatcher(self, value) {
                              return function recur(pool) {
                                var fn = null
                                if (_.isArr(pool)) {
                                  fn = pool.shift()
                            Severity: Minor
                            Found in lib/task.js - About 55 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 uuid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            exports.uuid = function () {
                              var uuid = '', i, random
                              for (i = 0; i < 32; i++) {
                                random = Math.random() * 16 | 0;
                                if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-'
                            Severity: Minor
                            Found in lib/utils.js - About 45 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 findBestAvailableThread has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function findBestAvailableThread(threads, offset) {
                              var thread, pending
                              for (var i = 0, l = threads.length; i < l; i += 1) {
                                thread = threads[i]
                                pending = thread.pending()
                            Severity: Minor
                            Found in lib/pool.js - About 45 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 exec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            Task.prototype.run = Task.prototype.exec = function (fn, env, args) {
                              var thread = this.thread
                            
                              if (!thread || thread._terminated) {
                                throw new Error('cannot execute the task. The thread was terminated')
                            Severity: Minor
                            Found in lib/task.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 removeEventListener has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            FakeWorker.prototype.removeEventListener = function (type, fn) {
                              var index, pool = this.listeners[type]
                              if (pool) {
                                if (_.isFn(fn)) {
                                  pool.splice(0, pool.length)
                            Severity: Minor
                            Found in lib/fake-worker.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