lexmihaylov/AsyncUtils

View on GitHub

Showing 12 of 12 total issues

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

var Thread = (function() {
    
    /**
     * a template function used to construct the webworker's content
     */
Severity: Major
Found in src/Thread.js - About 2 hrs to fix

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

    var Loop = (function() {
        /**
         * Async loop class that takes a handle as a parameter and a maximum number of iterations
         * @constructor
         * @param {Function} handle
    Severity: Major
    Found in src/Loop.js - About 2 hrs to fix

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

      var List = (function() {
          /**
           * Async array usage
           * @class ListHandler
           * @param {Array} list
      Severity: Major
      Found in src/List.js - About 2 hrs to fix

        Function ListHandler has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var ListHandler = (function() {
                
                var ListHandler = function(list) {
                    this.list = list;
                };
        Severity: Major
        Found in src/List.js - About 2 hrs to fix

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

          var If = (function() {
              /**
               * Proxy class for handling promises
               * @class ForkPromiseProxy
               */
          Severity: Minor
          Found in src/IfElse.js - About 1 hr to fix

            Function Loop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            var Loop = (function() {
                /**
                 * Async loop class that takes a handle as a parameter and a maximum number of iterations
                 * @constructor
                 * @param {Function} handle
            Severity: Minor
            Found in src/Loop.js - About 1 hr 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 Thread has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            var Thread = (function() {
                
                /**
                 * a template function used to construct the webworker's content
                 */
            Severity: Minor
            Found in src/Thread.js - About 1 hr 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 ForkPromiseProxy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var ForkPromiseProxy = (function() {
                    var ForkPromiseProxy = function(promise) {
                        this.promise = promise;
                        
                        this.thenHandle = function() {};
            Severity: Minor
            Found in src/IfElse.js - About 1 hr to fix

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

              var If = (function() {
                  /**
                   * Proxy class for handling promises
                   * @class ForkPromiseProxy
                   */
              Severity: Minor
              Found in src/IfElse.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 bind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                Function.prototype.bind = function(oThis) {
                  if (typeof this !== 'function') {
                    // closest thing possible to the ECMAScript 5
                    // internal IsCallable function
                    throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
              Severity: Minor
              Found in src/bind-polyfill.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

              unnecessary '.call()'.
              Open

                          if(this.handle.call(this)){
              Severity: Minor
              Found in src/Loop.js by eslint

              Disallow unnecessary .call() and .apply(). (no-useless-call)

              The function invocation can be written by Function.prototype.call() and Function.prototype.apply(). But Function.prototype.call() and Function.prototype.apply() are slower than the normal function invocation.

              Rule Details

              This rule is aimed to flag usage of Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation.

              Examples of incorrect code for this rule:

              /*eslint no-useless-call: "error"*/
              
              // These are same as `foo(1, 2, 3);`
              foo.call(undefined, 1, 2, 3);
              foo.apply(undefined, [1, 2, 3]);
              foo.call(null, 1, 2, 3);
              foo.apply(null, [1, 2, 3]);
              
              // These are same as `obj.foo(1, 2, 3);`
              obj.foo.call(obj, 1, 2, 3);
              obj.foo.apply(obj, [1, 2, 3]);

              Examples of correct code for this rule:

              /*eslint no-useless-call: "error"*/
              
              // The `this` binding is different.
              foo.call(obj, 1, 2, 3);
              foo.apply(obj, [1, 2, 3]);
              obj.foo.call(null, 1, 2, 3);
              obj.foo.apply(null, [1, 2, 3]);
              obj.foo.call(otherObj, 1, 2, 3);
              obj.foo.apply(otherObj, [1, 2, 3]);
              
              // The argument list is variadic.
              foo.apply(undefined, args);
              foo.apply(null, args);
              obj.foo.apply(obj, args);

              Known Limitations

              This rule compares code statically to check whether or not thisArg is changed. So if the code about thisArg is a dynamic expression, this rule cannot judge correctly.

              Examples of incorrect code for this rule:

              /*eslint no-useless-call: "error"*/
              
              a[i++].foo.call(a[i++], 1, 2, 3);

              Examples of correct code for this rule:

              /*eslint no-useless-call: "error"*/
              
              a[++i].foo.call(a[i], 1, 2, 3);

              When Not To Use It

              If you don't want to be notified about unnecessary .call() and .apply(), you can safely disable this rule. Source: http://eslint.org/docs/rules/

              Function prototype is read only, properties should not be added.
              Open

                Function.prototype.bind = function(oThis) {
              Severity: Minor
              Found in src/bind-polyfill.js by eslint

              Disallow Extending of Native Objects (no-extend-native)

              In JavaScript, you can extend any object, including builtin or "native" objects. Sometimes people change the behavior of these native objects in ways that break the assumptions made about them in other parts of the code.

              For example here we are overriding a builtin method that will then affect all Objects, even other builtins.

              // seems harmless
              Object.prototype.extra = 55;
              
              // loop through some userIds
              var users = {
                  "123": "Stan",
                  "456": "David"
              };
              
              // not what you'd expect
              for (var id in users) {
                  console.log(id); // "123", "456", "extra"
              }

              A common suggestion to avoid this problem would be to wrap the inside of the for loop with users.hasOwnProperty(id). However, if this rule is strictly enforced throughout your codebase you won't need to take that step.

              Rule Details

              Disallows directly modifying the prototype of builtin objects.

              Examples of incorrect code for this rule:

              /*eslint no-extend-native: "error"*/
              
              Object.prototype.a = "a";
              Object.defineProperty(Array.prototype, "times", { value: 999 });

              Options

              This rule accepts an exceptions option, which can be used to specify a list of builtins for which extensions will be allowed.

              exceptions

              Examples of correct code for the sample { "exceptions": ["Object"] } option:

              /*eslint no-extend-native: ["error", { "exceptions": ["Object"] }]*/
              
              Object.prototype.a = "a";

              Known Limitations

              This rule does not report any of the following less obvious approaches to modify the prototype of builtin objects:

              var x = Object;
              x.prototype.thing = a;
              
              eval("Array.prototype.forEach = 'muhahaha'");
              
              with(Array) {
                  prototype.thing = 'thing';
              };
              
              window.Function.prototype.bind = 'tight';

              When Not To Use It

              You may want to disable this rule when working with polyfills that try to patch older versions of JavaScript with the latest spec, such as those that might Function.prototype.bind or Array.prototype.forEach in a future-friendly way.

              Related Rules

              Severity
              Category
              Status
              Source
              Language