oglimmer/ggo

View on GitHub
web/src/main/webapp/js/lib/watch-1.3.0.js

Summary

Maintainability
F
5 days
Test Coverage

File watch-1.3.0.js has 627 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * THIS VERSION 1.3
 * 
 * DEVELOPED BY
 * GIL LOPES BUENO
Severity: Major
Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 day to fix

    Function defineWatcher has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var defineWatcher = function (obj, prop, watcher, level) {
            var newWatcher = false;
            var isArr = isArray(obj);
            
            if (!obj.watchers) {
    Severity: Major
    Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 3 hrs to fix

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

          var trackObject= function(obj, callback, recursive, addNRemove) {
              var change = null,lastTimerID = -1;
              var isArr = isArray(obj);
              var level,fn = function(prop, action, newValue, oldValue) {
                  var timerID = getTimerID();
      Severity: Minor
      Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

        Function loop has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var loop = function(){
        
                // check for new or deleted props
                for(var i=0; i<lengthsubjects.length; i++) {
        
        
        Severity: Minor
        Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

          Function defineArrayMethodWatcher has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var defineArrayMethodWatcher = function (obj, original, methodName, callback) {
                  defineProp(obj, methodName, function () {
                      var index = 0;
                      var i,newValue, oldValue, response;                        
                      // get values before splicing array 
          Severity: Minor
          Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

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

                    var level,fn = function(prop, action, newValue, oldValue) {
                        var timerID = getTimerID();
                        if (lastTimerID!==timerID) { // check if timer has changed since last update
                            lastTimerID = timerID;
                            change = {
            Severity: Minor
            Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

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

                  var getObjDiff = function(a, b){
                      var aplus = [],
                      bplus = [];
              
                      if(!(typeof a == "string") && !(typeof b == "string")){
              Severity: Minor
              Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

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

                    var defineGetAndSet = function (obj, propName, getter, setter) {
                        try {
                            Object.observe(obj, function(changes) {
                                changes.forEach(function(change) {
                                    if (change.name === propName) {
                Severity: Minor
                Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

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

                      var watchAll = function (obj, watcher, level, addNRemove) {
                  
                          if ((typeof obj == "string") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)
                              return;
                          }
                  Severity: Minor
                  Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (action!=='splice') {
                                                    watchAll(newValue, watchList[i], (level===undefined)?level:level-1);
                                                }
                                                else {
                                                    // watch spliced values
                    Severity: Major
                    Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if(b[i] === undefined) {
                                                  aplus.push(i);
                                              }
                      Severity: Major
                      Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                for (var j=0; j<subj.obj.watchers[subj.prop].length; j++) {
                                                    watchMany(subj.obj[subj.prop], difference.added, subj.obj.watchers[subj.prop][j], subj.level - 1, true);
                                                }
                        Severity: Major
                        Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if(a[j] === undefined) {
                                                      bplus.push(j);
                                                  }
                          Severity: Major
                          Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 45 mins to fix

                            Function watchOne has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                var watchOne = function (obj, prop, watcher, level, addNRemove) {
                            Severity: Minor
                            Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 35 mins to fix

                              Function callWatchers has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  var callWatchers = function (obj, prop, action, newval, oldval) {
                              Severity: Minor
                              Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 35 mins to fix

                                Function watchMany has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    var watchMany = function (obj, props, watcher, level, addNRemove) {
                                Severity: Minor
                                Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 35 mins to fix

                                  Function trackProperty has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      var trackProperty = function(obj,prop,callback,recursive, addNRemove) { 
                                  Severity: Minor
                                  Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 35 mins to fix

                                    Function addPendingChange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        var addPendingChange = function(obj,prop, mode, newval, oldval) {
                                    Severity: Minor
                                    Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 35 mins to fix

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                                  if (isArray(a)) {
                                                      for (var i=0; i<a.length; i++) {
                                                          if (b[i] === undefined) aplus.push(i);
                                                      }
                                                  } else {
                                      Severity: Major
                                      Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 4 hrs to fix
                                      web/src/main/webapp/js/lib/watch-1.3.0.js on lines 86..98

                                      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 119.

                                      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

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                                  if (isArray(b)) {
                                                      for (var j=0; j<b.length; j++) {
                                                          if (a[j] === undefined) bplus.push(j);
                                                      }
                                                  } else {
                                      Severity: Major
                                      Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 4 hrs to fix
                                      web/src/main/webapp/js/lib/watch-1.3.0.js on lines 72..84

                                      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 119.

                                      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

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          var watch = function () {
                                      
                                              if (isFunction(arguments[1])) {
                                                  watchAll.apply(this, arguments);
                                              } else if (isArray(arguments[1])) {
                                      Severity: Major
                                      Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 2 hrs to fix
                                      web/src/main/webapp/js/lib/watch-1.3.0.js on lines 262..272

                                      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 83.

                                      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

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          var unwatch = function () {
                                      
                                              if (isFunction(arguments[1])) {
                                                  unwatchAll.apply(this, arguments);
                                              } else if (isArray(arguments[1])) {
                                      Severity: Major
                                      Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 2 hrs to fix
                                      web/src/main/webapp/js/lib/watch-1.3.0.js on lines 181..191

                                      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 83.

                                      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