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
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) {
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();
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++) {
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
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 = {
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")){
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) {
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;
}
Avoid deeply nested control flow statements. Open
if (action!=='splice') {
watchAll(newValue, watchList[i], (level===undefined)?level:level-1);
}
else {
// watch spliced values
Avoid deeply nested control flow statements. Open
if(b[i] === undefined) {
aplus.push(i);
}
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);
}
Avoid deeply nested control flow statements. Open
if(a[j] === undefined) {
bplus.push(j);
}
Function watchOne
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var watchOne = function (obj, prop, watcher, level, addNRemove) {
Function callWatchers
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var callWatchers = function (obj, prop, action, newval, oldval) {
Function watchMany
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var watchMany = function (obj, props, watcher, level, addNRemove) {
Function trackProperty
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var trackProperty = function(obj,prop,callback,recursive, addNRemove) {
Function addPendingChange
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var addPendingChange = function(obj,prop, mode, newval, oldval) {
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 {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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])) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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])) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76