cfpb/owning-a-home

View on GitHub
src/static/js/modules/object.observe-polyfill.js

Summary

Maintainability
D
2 days
Test Coverage

Function Notifier has 158 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var Notifier = function(watching){
    var _listeners = [], _acceptLists = [], _updates = [], _updater = false, properties = [], values = [];
      var self = this;
      Object.defineProperty(self, '_watching', {
                  enumerable: true,
Severity: Major
Found in src/static/js/modules/object.observe-polyfill.js - About 6 hrs to fix

    Consider simplifying this complex logical expression.
    Open

    if(supportsAccessors && !Object.observe){
      (function(extend, global){
        var isCallable = (function(toString){
            var s = toString.call(toString),
                u = typeof u;
    Severity: Critical
    Found in src/static/js/modules/object.observe-polyfill.js - About 5 hrs to fix

      File object.observe-polyfill.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var supportsAccessors = require('./supports-accessors');
      
      // The polyfill below is from https://github.com/jdarling/Object.observe
      
      /*
      Severity: Minor
      Found in src/static/js/modules/object.observe-polyfill.js - About 3 hrs to fix

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

              self._checkPropertyListing = function(dontQueueUpdates){
                var object = self._watching, keys = Object.keys(object), i=0, l=keys.length;
                var newKeys = [], oldKeys = properties.slice(0), updates = [];
                var prop, queueUpdates = !dontQueueUpdates, propType, value, idx, aLength;
        
        
        Severity: Minor
        Found in src/static/js/modules/object.observe-polyfill.js - About 1 hr to fix

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

              var Observer = (function(){
                var wraped = [];
                var Observer = function(O, callback, accept){
                  validateArguments(O, callback, accept);
                  if (!accept) {
          Severity: Minor
          Found in src/static/js/modules/object.observe-polyfill.js - About 1 hr to fix

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

                  var wrapProperty = function(object, prop){
                    var propType = typeof(object[prop]), descriptor = Object.getOwnPropertyDescriptor(object, prop);
                    if((prop==='getNotifier')||isAccessorDescriptor(descriptor)||(!descriptor.enumerable)){
                      return false;
                    }
            Severity: Minor
            Found in src/static/js/modules/object.observe-polyfill.js - About 1 hr to fix

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

                    self.deliverChangeRecords = function(){
                      var i = 0, l = _listeners.length,
                          //keepRunning = true, removed as it seems the actual implementation doesn't do this
                          // In response to BUG #5
                          retval;
              Severity: Minor
              Found in src/static/js/modules/object.observe-polyfill.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                              if(values[idx] !== value){
                                if(queueUpdates){
                                  self.queueUpdate(object, prop, 'update', values[idx], value);
                                }
                                values[idx] = value;
                Severity: Major
                Found in src/static/js/modules/object.observe-polyfill.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                for (var j = 0, updatesLength = _updates.length; j < updatesLength; j++) {
                                  if (_acceptLists[i].indexOf(_updates[j].type) !== -1) {
                                    currentUpdates.push(_updates[j]);
                                  }
                                }
                  Severity: Major
                  Found in src/static/js/modules/object.observe-polyfill.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if(_listeners[i]===console.log){
                                    console.log(currentUpdates);
                                  }else{
                                    _listeners[i](currentUpdates);
                                  }
                    Severity: Major
                    Found in src/static/js/modules/object.observe-polyfill.js - About 45 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status