1
|
|
|
!function(c){c.fn.incrementDigitByModel=function(t,u,n,e){if("string"!=typeof t)return t;e=e||"___i___",n=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");e=new RegExp("^(.+?)("+e+")(.*?)$","g");return n=n.replace(e,"($1)(\\d+)($3.*?)"),e=new RegExp(n),t=t.replace(e,function(t,n,e,r){return u=void 0===u?e:u,n+(Number(u)+1)+r})},c.fn.incrementAttributes=function(t,e,r,u){var i=c(this);c.each(t,function(t,n){i.incrementAttribute(n,e,r,u)})},c.fn.incrementAttribute=function(t,e,r,u){return this.attr(t,function(t,n){return c(this).incrementDigitByModel(n,e,r,u)})},c.fn.incrementIDAttribute=function(t,e){return this.attr(t,function(t,n){return u(t,n,1,e)})},c.fn.incrementNameAttribute=function(t,e){return this.attr(t,function(t,n){return i(t,n,1,e)})},c.fn.decrementIDAttribute=function(t,e){return this.attr(t,function(t,n){return u(t,n,-1,e)})},c.fn.decrementNameAttribute=function(t,e){return this.attr(t,function(t,n){return i(t,n,-1,e)})},c.fn.setIndexIDAttribute=function(t,e,r){return this.attr(t,function(t,n){return u(e,n,0,r)})},c.fn.setIndexNameAttribute=function(t,e,r){return this.attr(t,function(t,n){return i(e,n,0,r)})};function a(t){return void 0===t?-1:!0===t?1:!1!==t&&0!==t&&"number"==typeof t?t:-1}var u=function(u,t,i,n){if(void 0===t)return t;var c=1,e=new RegExp("(.+?)__(\\d+)(?=([_-]|$))","g"),r=t.match(e),r=null!==r&&r.hasOwnProperty("length")?r.length:0;if(0===r)return t;var f=(f=a(n))<0?r+1+f:f;return t.replace(e,function(t,n,e){if(c!==f)return c++,t;var r="";switch(i){case 1:r=n+"__"+(Number(e)+1);break;case-1:r=n+"__"+(Number(e)-1);break;default:r=n+"__"+u}return c++,r})},i=function(u,t,i,n){if(void 0===t)return t;var c=1,e=new RegExp("(.+?)\\[(\\d+)(?=\\])","g"),r=t.match(e),r=null!==r&&r.hasOwnProperty("length")?r.length:0;if(0===r)return t;var f=(f=a(n))<0?r+1+f:f;return t.replace(e,function(t,n,e){if(c!==f)return c++,t;var r="";switch(i){case 1:r=n+"["+(Number(e)+1);break;case-1:r=n+"["+(Number(e)-1);break;default:r=n+"["+u}return c++,r})}}(jQuery); |
This check looks for variables that are declared in multiple lines. There may be several reasons for this.
In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.
If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.