src/ng/rootScope.js
Function $RootScopeProvider
has a Cognitive Complexity of 462 (exceeds 5 allowed). Consider refactoring. Open
Open
function $RootScopeProvider() {
var TTL = 10;
var $rootScopeMinErr = minErr('$rootScope');
var lastDirtyWatch = null;
var applyAsyncId = null;
- Read upRead up
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
Open
function $RootScopeProvider() {
var TTL = 10;
var $rootScopeMinErr = minErr('$rootScope');
var lastDirtyWatch = null;
var applyAsyncId = null;
Function $get
has 566 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function($exceptionHandler, $parse, $browser) {
function destroyChildScope($event) {
$event.currentScope.$$destroyed = true;
}
File rootScope.js
has 596 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
/**
* DESIGN NOTES
*
Function $watchCollection
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function $digest
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$digest: function() {
var watch, value, last, fn, get,
watchers,
dirty, ttl = TTL,
next, current, target = asyncQueue.length ? $rootScope : this,
Function $watchCollectionInterceptor
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function $watchGroup
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$watchGroup: function(watchExpressions, listener) {
var oldValues = new Array(watchExpressions.length);
var newValues = new Array(watchExpressions.length);
var deregisterFns = [];
var self = this;
Function $broadcast
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$broadcast: function(name, args) {
var target = this,
current = target,
next = target,
event = {
Function $emit
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$emit: function(name, args) {
var empty = [],
namedListeners,
scope = this,
stopPropagation = false,
Function $watch
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$watch: function(watchExp, listener, objectEquality, prettyPrintExpression) {
var get = $parse(watchExp);
var fn = isFunction(listener) ? listener : noop;
if (get.$$watchDelegate) {
Avoid deeply nested control flow statements. Open
Open
if (watch) {
get = watch.get;
if ((value = get(current)) !== (last = watch.last) &&
!(watch.eq
? equals(value, last)
Avoid deeply nested control flow statements. Open
Open
if (key in oldValue) {
// eslint-disable-next-line no-self-compare
bothNaN = (oldItem !== oldItem) && (newItem !== newItem);
if (!bothNaN && (oldItem !== newItem)) {
changeDetected++;
Avoid deeply nested control flow statements. Open
Open
if (!hasOwnProperty.call(newValue, key)) {
oldLength--;
delete oldValue[key];
}
Consider simplifying this complex logical expression. Open
Open
if (!(next = ((!current.$$suspended && current.$$watchersCount && current.$$childHead) ||
(current !== target && current.$$nextSibling)))) {
while (current !== target && !(next = current.$$nextSibling)) {
current = current.$parent;
}