angular/angular.js

View on GitHub
src/jqLite.js

Summary

Maintainability
F
5 days
Test Coverage

File jqLite.js has 759 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *     Any commits to this file should be reviewed with security in mind.  *
 *   Changes to this file can potentially create security vulnerabilities. *
Severity: Major
Found in src/jqLite.js - About 1 day to fix

    Function createEventHandler has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function createEventHandler(element, events) {
      var eventHandler = function(event, type) {
        // jQuery specific api
        event.isDefaultPrevented = function() {
          return event.defaultPrevented;
    Severity: Minor
    Found in src/jqLite.js - About 3 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 jqLiteOff has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function jqLiteOff(element, type, fn, unsupported) {
      if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument');
    
      var expandoStore = jqLiteExpandoStore(element);
      var events = expandoStore && expandoStore.events;
    Severity: Minor
    Found in src/jqLite.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 jqLiteAddNodes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function jqLiteAddNodes(root, elements) {
      // THIS CODE IS VERY HOT. Don't make changes without benchmarking.
    
      if (elements) {
    
    
    Severity: Minor
    Found in src/jqLite.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 jqLiteData has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function jqLiteData(element, key, value) {
      if (jqLiteAcceptsData(element)) {
        var prop;
    
        var isSimpleSetter = isDefined(value);
    Severity: Minor
    Found in src/jqLite.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 attr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      attr: function(element, name, value) {
        var ret;
        var nodeType = element.nodeType;
        if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT ||
          !element.getAttribute) {
    Severity: Minor
    Found in src/jqLite.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 jqLiteBuildFragment has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    function jqLiteBuildFragment(html, context) {
      var tmp, tag, wrap, finalHtml,
          fragment = context.createDocumentFragment(),
          nodes = [], i;
    
    
    Severity: Minor
    Found in src/jqLite.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 jqLiteOn has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      on: function jqLiteOn(element, type, fn, unsupported) {
        if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
    
        // Do not add event handlers to non-elements because they will not be cleaned up.
        if (!jqLiteAcceptsData(element)) {
    Severity: Minor
    Found in src/jqLite.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 jqLiteBuildFragment has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function jqLiteBuildFragment(html, context) {
      var tmp, tag, wrap, finalHtml,
          fragment = context.createDocumentFragment(),
          nodes = [], i;
    
    
    Severity: Minor
    Found in src/jqLite.js - About 1 hr to fix

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

      function createEventHandler(element, events) {
        var eventHandler = function(event, type) {
          // jQuery specific api
          event.isDefaultPrevented = function() {
            return event.defaultPrevented;
      Severity: Minor
      Found in src/jqLite.js - About 1 hr to fix

        Function jqLiteOn has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          on: function jqLiteOn(element, type, fn, unsupported) {
            if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
        
            // Do not add event handlers to non-elements because they will not be cleaned up.
            if (!jqLiteAcceptsData(element)) {
        Severity: Minor
        Found in src/jqLite.js - About 1 hr to fix

          Function jqLiteOff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function jqLiteOff(element, type, fn, unsupported) {
            if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument');
          
            var expandoStore = jqLiteExpandoStore(element);
            var events = expandoStore && expandoStore.events;
          Severity: Minor
          Found in src/jqLite.js - About 1 hr to fix

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

              JQLite.prototype[name] = function(arg1, arg2) {
                var i, key;
                var nodeCount = this.length;
            
                // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
            Severity: Minor
            Found in src/jqLite.js - About 1 hr to fix

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

                var eventHandler = function(event, type) {
                  // jQuery specific api
                  event.isDefaultPrevented = function() {
                    return event.defaultPrevented;
                  };
              Severity: Minor
              Found in src/jqLite.js - About 1 hr to fix

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

                  triggerHandler: function(element, event, extraParameters) {
                
                    var dummyEvent, eventFnsCopy, handlerArgs;
                    var eventName = event.type || event;
                    var expandoStore = jqLiteExpandoStore(element);
                Severity: Minor
                Found in src/jqLite.js - About 1 hr to fix

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

                  function jqLiteInheritedData(element, name, value) {
                    // if element is the document object work with the html element instead
                    // this makes $(document).scope() possible
                    if (element.nodeType === NODE_TYPE_DOCUMENT) {
                      element = element.documentElement;
                  Severity: Minor
                  Found in src/jqLite.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 JQLite has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function JQLite(element) {
                    if (element instanceof JQLite) {
                      return element;
                    }
                  
                  
                  Severity: Minor
                  Found in src/jqLite.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 $$jqLiteProvider has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function $$jqLiteProvider() {
                    this.$get = function $$jqLite() {
                      return extend(JQLite, {
                        hasClass: function(node, classes) {
                          if (node.attr) node = node[0];
                  Severity: Minor
                  Found in src/jqLite.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

                  Avoid deeply nested control flow statements.
                  Open

                            for (var i = 0; i < length; i++) {
                              root[root.length++] = elements[i];
                            }
                  Severity: Major
                  Found in src/jqLite.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              for (prop in key) {
                                data[kebabToCamel(prop)] = key[prop];
                              }
                    Severity: Major
                    Found in src/jqLite.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  for (key in arg1) {
                                    fn(this[i], key, arg1[key]);
                                  }
                      Severity: Major
                      Found in src/jqLite.js - About 45 mins to fix

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

                          triggerHandler: function(element, event, extraParameters) {
                        
                            var dummyEvent, eventFnsCopy, handlerArgs;
                            var eventName = event.type || event;
                            var expandoStore = jqLiteExpandoStore(element);
                        Severity: Minor
                        Found in src/jqLite.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 toggleClass has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          toggleClass: function(element, selector, condition) {
                            if (selector) {
                              forEach(selector.split(' '), function(className) {
                                var classCondition = condition;
                                if (isUndefined(classCondition)) {
                        Severity: Minor
                        Found in src/jqLite.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 text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          text: (function() {
                            getText.$dv = '';
                            return getText;
                        
                            function getText(element, value) {
                        Severity: Minor
                        Found in src/jqLite.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

                        var jqLiteContains = window.Node.prototype.contains || /** @this */ function(arg) {
                          // eslint-disable-next-line no-bitwise
                          return !!(this.compareDocumentPosition(arg) & 16);
                        };
                        Severity: Minor
                        Found in src/jqLite.js and 1 other location - About 35 mins to fix
                        src/ngSanitize/sanitize.js on lines 319..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 46.

                        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