angular/angular.js

View on GitHub
src/ng/rootScope.js

Summary

Maintainability
F
2 wks
Test Coverage

Function $RootScopeProvider has a Cognitive Complexity of 462 (exceeds 5 allowed). Consider refactoring.
Open

function $RootScopeProvider() {
  var TTL = 10;
  var $rootScopeMinErr = minErr('$rootScope');
  var lastDirtyWatch = null;
  var applyAsyncId = null;
Severity: Minor
Found in src/ng/rootScope.js - About 1 wk 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 $RootScopeProvider has 593 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function $RootScopeProvider() {
  var TTL = 10;
  var $rootScopeMinErr = minErr('$rootScope');
  var lastDirtyWatch = null;
  var applyAsyncId = null;
Severity: Major
Found in src/ng/rootScope.js - About 2 days to fix

    Function $get has 566 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function($exceptionHandler, $parse, $browser) {
    
        function destroyChildScope($event) {
            $event.currentScope.$$destroyed = true;
        }
    Severity: Major
    Found in src/ng/rootScope.js - About 2 days to fix

      File rootScope.js has 596 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      /**
       * DESIGN NOTES
       *
      Severity: Major
      Found in src/ng/rootScope.js - About 1 day to fix

        Function $watchCollection has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              $watchCollection: function(obj, listener) {
                // Mark the interceptor as
                // ... $$pure when literal since the instance will change when any input changes
                $watchCollectionInterceptor.$$pure = $parse(obj).literal;
                // ... $stateful when non-literal since we must read the state of the collection
        Severity: Major
        Found in src/ng/rootScope.js - About 4 hrs to fix

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

                $digest: function() {
                  var watch, value, last, fn, get,
                      watchers,
                      dirty, ttl = TTL,
                      next, current, target = asyncQueue.length ? $rootScope : this,
          Severity: Major
          Found in src/ng/rootScope.js - About 3 hrs to fix

            Function $watchCollectionInterceptor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function $watchCollectionInterceptor(_value) {
                      newValue = _value;
                      var newLength, key, bothNaN, newItem, oldItem;
            
                      // If the new value is undefined, then return undefined as the watch may be a one-time watch
            Severity: Major
            Found in src/ng/rootScope.js - About 2 hrs to fix

              Function $watchGroup has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    $watchGroup: function(watchExpressions, listener) {
                      var oldValues = new Array(watchExpressions.length);
                      var newValues = new Array(watchExpressions.length);
                      var deregisterFns = [];
                      var self = this;
              Severity: Major
              Found in src/ng/rootScope.js - About 2 hrs to fix

                Function $broadcast has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      $broadcast: function(name, args) {
                        var target = this,
                            current = target,
                            next = target,
                            event = {
                Severity: Minor
                Found in src/ng/rootScope.js - About 1 hr to fix

                  Function $emit has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        $emit: function(name, args) {
                          var empty = [],
                              namedListeners,
                              scope = this,
                              stopPropagation = false,
                  Severity: Minor
                  Found in src/ng/rootScope.js - About 1 hr to fix

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

                          $watch: function(watchExp, listener, objectEquality, prettyPrintExpression) {
                            var get = $parse(watchExp);
                            var fn = isFunction(listener) ? listener : noop;
                    
                            if (get.$$watchDelegate) {
                    Severity: Minor
                    Found in src/ng/rootScope.js - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                        if (watch) {
                                          get = watch.get;
                                          if ((value = get(current)) !== (last = watch.last) &&
                                              !(watch.eq
                                                  ? equals(value, last)
                      Severity: Major
                      Found in src/ng/rootScope.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        if (key in oldValue) {
                                          // eslint-disable-next-line no-self-compare
                                          bothNaN = (oldItem !== oldItem) && (newItem !== newItem);
                                          if (!bothNaN && (oldItem !== newItem)) {
                                            changeDetected++;
                        Severity: Major
                        Found in src/ng/rootScope.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          if (!hasOwnProperty.call(newValue, key)) {
                                            oldLength--;
                                            delete oldValue[key];
                                          }
                          Severity: Major
                          Found in src/ng/rootScope.js - About 45 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                        if (!(next = ((!current.$$suspended && current.$$watchersCount && current.$$childHead) ||
                                            (current !== target && current.$$nextSibling)))) {
                                          while (current !== target && !(next = current.$$nextSibling)) {
                                            current = current.$parent;
                                          }
                            Severity: Major
                            Found in src/ng/rootScope.js - About 40 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status