Conditions | 20 |
Paths | 1584 |
Total Lines | 1 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Metric | Value |
---|---|
c | 0 |
b | 0 |
f | 0 |
dl | 0 |
loc | 1 |
rs | 2 |
cc | 20 |
nc | 1584 |
nop | 5 |
Complex classes like A(ꞌtwig.attrꞌ) often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
1 | /** |
||
2 | * twig.js |
||
3 | * https://github.com/schmittjoh/twig.js |
||
4 | * |
||
5 | * (C) 2011 Johannes M. Schmitt <[email protected]> |
||
6 | * Licensed under the Apache 2.0 License. |
||
7 | * |
||
8 | * Portions of this code are from the Google Closure Library received |
||
9 | * from the Closure Authors under the Apache 2.0 License. |
||
10 | */ |
||
11 | (function() {var e=void 0,g=!0,i=null,l=!1;function m(a){return function(){return this[a]}}var n,p=this;function q(a,b,c){a=a.split(".");c=c||p;!(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&b!==e?c[d]=b:c=c[d]?c[d]:c[d]={}} |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
12 | function r(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
13 | else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function s(a){return"array"==r(a)}function t(a){return"string"==typeof a}function u(a){var b=typeof a;return"object"==b&&a!=i||"function"==b}var v="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),w=0;function x(a,b,c){return a.call.apply(a.bind,arguments)} |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
14 | function y(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function z(a,b,c){z=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?x:y;return z.apply(i,arguments)}function A(a,b){q(a,b,e)};var B=/&/g,C=/</g,D=/>/g,E=/\"/g,F=/[&<>\"]/,G={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\"},H={"'":"\\'"};function I(a,b){a!=i&&this.append.apply(this,arguments)}I.prototype.b="";I.prototype.append=function(a,b,c){this.b+=a;if(b!=i)for(var d=1;d<arguments.length;d++)this.b+=arguments[d];return this};I.prototype.toString=m("b");function J(a,b,c){for(var d in a)b.call(c,a[d],d,a)}function K(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function L(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}var M="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function N(a,b){for(var c,d,f=1;f<arguments.length;f++){d=arguments[f];for(c in d)a[c]=d[c];for(var h=0;h<M.length;h++)c=M[h],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};var O=Array.prototype,P=O.indexOf?function(a,b,c){return O.indexOf.call(a,b,c)}:function(a,b,c){c=c==i?0:0>c?Math.max(0,a.length+c):c;if(t(a))return!t(b)||1!=b.length?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},aa=O.forEach?function(a,b,c){O.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,f=t(a)?a.split(""):a,h=0;h<d;h++)h in f&&b.call(c,f[h],h,a)};var ba=z,v="twig_ui_"+Math.floor(2147483648*Math.random()).toString(36);function R(a){return i===a||l===a||e===a||0===a?g:S(a)?0===T(a):l}function U(a,b){N.apply(i,Array.prototype.slice.call(arguments,0));return a}function S(a){return s(a)||t(a)||u(a)}function T(a){if(s(a))a=a.length;else if(t(a))a=a.length;else if(u(a)){var b=0,c;for(c in a)b++;a=b}else a=("number"===typeof a?a.toString():"").length;return a}function V(a,b,c){s(a)?aa(a,b,c):J(a,b,c)} |
||
0 ignored issues
–
show
The variable
v already seems to be declared on line 13 . Consider using another variable name or omitting the var keyword.
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. ![]() Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() A for in loop automatically includes the property of any prototype object, consider checking the key using
hasOwnProperty .
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: var someObject;
for (var key in someObject) {
if ( ! someObject.hasOwnProperty(key)) {
continue; // Skip keys from the prototype.
}
doSomethingWith(key);
}
![]() Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() |
|||
15 | function W(a){return a.replace(/[\.\\+*?\[\]<>(){}^$=!|:-]/g,"\\$&")};function X(a){this.env_=a;this.c=[];this.m={}}n=X.prototype;n.s=m("c");n.C=function(a){this.c=a};n.K=function(a){this.m=a};n.getParent=function(a){a=this.getParent_(a);return l===a?l:this.env_.d(a)};n.B=function(a,b,c){if(a in this.m){var d=new I;this.m[a](d,b,c||{});return d.toString()}d=this.getParent(b);if(l!==d)return d.k(a,b,c);throw Error("The template '"+this.o()+"' has no parent, and no trait defining the block '"+a+"'.");}; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
16 | n.k=function(a,b,c){if(c&&a in c){var d=new I,f=c[a];delete c[a];f(d,b,c);return d.toString()}if(a in this.c)return d=new I,this.c[a](d,b,c||i),d.toString();d=this.getParent(b);return l!==d?d.k(a,b,c):""};n.j=function(a,b){var c=new I;this.render_(c,a||{},b||{});return c.toString()}; |
||
0 ignored issues
–
show
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
17 | n.q=function(a,b,c,d){if(!a["get"+b])throw Error("The macro "+b+" is not defined in "+a.o()+".");if(d===e)return a["get"+b].apply(a,c);throw Error("Positional arguments, or default values in macro arguments are not supported, yet.");};function Y(a){this.r=a}Y.prototype.toString=m("r");function Z(a,b,c,d,f){if(f&&b instanceof Y)return b.toString();b=b==i?"":String(b);if(ca===c){a=String(b);if(a.quote)b=a.quote();else{b=['"'];for(c=0;c<a.length;c++){var h=a.charAt(c),k=h.charCodeAt(0),d=b,f=c+1,j;if(!(j=G[h])){if(!(31<k&&127>k))if(h in H)h=H[h];else if(h in G)h=H[h]=G[h];else{k=h;j=h.charCodeAt(0);if(31<j&&127>j)k=h;else{if(256>j){if(k="\\x",16>j||256<j)k+="0"}else k="\\u",4096>j&&(k+="0");k+=j.toString(16).toUpperCase()}h=H[h]=k}j=h}d[f]=j}b.push('"');b=b.join("")}return b.substring(1, |
||
0 ignored issues
–
show
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
18 | b.length-1)}if(!c||da===c)return a=b,F.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(B,"&")),-1!=a.indexOf("<")&&(a=a.replace(C,"<")),-1!=a.indexOf(">")&&(a=a.replace(D,">")),-1!=a.indexOf('"')&&(a=a.replace(E,"""))),a;if(ea===c)return encodeURIComponent(b);throw Error("The type '"+c+"' is not supported.");}var da="html",ca="js",ea="url";function $(){this.a={};this.g={};this.h={};this.l={};this.f={};this.e={};this.p=l;this.L="UTF-8"}n=$.prototype;n.j=function(a,b){var c=this.d(a);return c.j.call(c,U({},this.e,b||{}))};n.filter=function(a,b,c){if(!(a in this.g))throw Error("The filter '"+a+"' does not exist.");return this.g[a].apply(i,Array.prototype.slice.call(arguments,1))};n.w=function(a,b,c){if(!(a in this.h))throw Error("The function '"+a+"' does not exist.");return this.h[a].apply(i,Array.prototype.slice.call(arguments,1))}; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() |
|||
19 | n.test=function(a,b,c){if(!(a in this.l))throw Error("The test '"+a+"' does not exist.");return this.l[a].apply(i,Array.prototype.slice.call(arguments,1))};n.escape=function(a,b,c,d){return Z(0,a,b,0,d)};n.z=function(a,b,c){var d=this.d(a),f=d["get"+b];if(!f)throw Error("The macro '"+b+"' does not exist on template '"+d.o()+"'.");return f.apply(d,Array.prototype.slice.call(arguments,2)).toString()};n.F=function(a,b){this.g[a]=b};n.G=function(a,b){this.h[a]=b};n.J=function(a,b){this.l[a]=b}; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
20 | n.I=function(a){this.e=a};n.H=function(a,b){this.e[a]=b};n.u=m("e");n.i=function(){this.p=g;J(this.a,function(a){a.i()},this)};n.v=function(a){return a in this.a};n.getExtension=function(a){if(!(a in this.a))throw Error('The "'+a+'" extension is not enabled.');return this.a[a]};n.n=function(a){this.a[a.getName()]=a};n.A=function(a){delete this.a[a]};n.D=function(a){J(a,function(a){this.n(a)})};n.t=m("a"); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
21 | n.d=function(a){var b=a[v]||(a[v]=++w);if(b in this.f)return this.f[b];l===this.p&&this.i();a=new a(this);return this.f[b]=a};window.Twig=new $;A("goog.provide",function(a){q(a)});A("goog.require",function(){}); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
22 | A("twig.attr",function(a,b,c,d,f){d=d||"any";f=f!==e?f:l;if(!u(a)&&!s(a))return f?l:i;if(b in a){if("array"!==d&&"function"==r(a[b]))return f?g:a[b].apply(a,c||[]);if("method"!==d)return f?g:a[b]}if("array"===d||s(a))return f?l:i;var b=b.toLowerCase(),h="get"+b,k="is"+b,j;a:{b=function(a,b){b=b.toLowerCase();return b===h||b===k};for(j in a)if(b.call(e,0,j))break a;j=e}return j&&"function"==r(a[j])?f?g:a[j].apply(a,c||[]):f?l:i});A("twig.bind",ba); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
23 | A("twig.inherits",function(a,b){function c(){}c.prototype=b.prototype;a.M=b.prototype;a.prototype=new c});A("twig.extend",U);A("twig.spaceless",function(a){return a.replace(/>[\s\xa0]+</g,"><").replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")});A("twig.range",function(a,b){for(var c=[];a<=b;a+=1)c.push(a);return c});A("twig.contains",function(a,b){var c;if(s(a))c=0<=P(a,b);else if(t(a))c=-1!=a.indexOf(b)&&(""!==b||""===a);else a:{for(c in a)if(a[c]==b){c=g;break a}c=l}return c});A("twig.countable",S); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
24 | A("twig.count",T);A("twig.forEach",V);A("twig.empty",R);A("twig.createObj",function(a){for(var b={},c=0;c<arguments.length;c+=2)b[arguments[c]]=arguments[c+1];return b});A("twig.pregQuote",W);A("twig.filter.capitalize",function(a,b){return b.charAt(0).toUpperCase()+b.substring(1)});A("twig.filter.escape",Z);A("twig.filter.first",function(a,b){return s(b)?b[0]:u(b)?b[Object.keys(b)[0]]:t(b)?b.charAt(0):""});A("twig.filter.length",function(a,b){return T(b)}); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
25 | A("twig.filter.def",function(a,b){return R(a)?b||"":a});A("twig.filter.replace",function(a,b){for(var c in b){var d;d=W(c);a=a.replace(RegExp(d,"g"),b[c])}return a});A("twig.filter.join",function(a,b){var c=b||"",d=new I,f=g;V(a,function(a){f||d.append(c);f=l;d.append(a)});return d.toString()});A("twig.filter.keys",L);A("twig.filter.upper",function(a,b){return b.toUpperCase()});A("twig.filter.lower",function(a,b){return b.toLowerCase()});A("twig.filter.nl2br",function(a){return a.replace(/\n/g,"<br />")}); |
||
0 ignored issues
–
show
A for in loop automatically includes the property of any prototype object, consider checking the key using
hasOwnProperty .
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: var someObject;
for (var key in someObject) {
if ( ! someObject.hasOwnProperty(key)) {
continue; // Skip keys from the prototype.
}
doSomethingWith(key);
}
![]() |
|||
26 | A("twig.filter.abs",function(a){return Math.abs(a)});A("twig.filter.title",function(a,b){return b.split(" ").map(function(a){return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase()}).join(" ")});A("twig.filter.trim",function(a,b){var c="\n ";b&&(c=W(b));a=a.replace(RegExp("^["+c+"]+"),"");return a=a.replace(RegExp("["+c+"]+$"),"")});A("twig.filter.json_encode",function(a){return JSON.stringify(a)}); |
||
0 ignored issues
–
show
|
|||
27 | A("twig.filter.last",function(a,b){if(s(b))return b[b.length-1];if(u(b)){var c=Object.keys(b);return b[c[c.length-1]]}return t(b)?b.charAt(b.length-1):""});A("twig.filter.reverse",function(a,b){if(s(b))return b.reverse();if(u(b)){for(var c={},d=L(b).reverse(),f=0;f<d.length;f++)c[d[f]]=b[d[f]];return c}return t(b)?b.split("").reverse().join(""):b}); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
28 | A("twig.filter.batch",function(a,b,c){for(var d=Array(Math.ceil(a.length/b)),f=d.length*b,h=0;h<f;h++){var k=Math.floor(h/b);"undefined"===typeof d[k]&&(d[k]=[]);"undefined"!==typeof a[h]?d[k].push(a[h]):t(c)&&d[k].push(c)}return d}); |
||
29 | A("twig.filter.merge",function(a,b){var c=[];if(s(a)&&s(b)){for(var d=c=a.concat(b),f={},h=0,k=0;k<d.length;){var j=d[k++],Q=u(j)?"o"+(j[v]||(j[v]=++w)):(typeof j).charAt(0)+j;Object.prototype.hasOwnProperty.call(f,Q)||(f[Q]=g,d[h++]=j)}d.length=h}else if(u(a)&&u(b)){d={};for(f in a)d[f]=a[f];c=d;J(b,function(a,b){c[b]=a})}return c});A("twig.functions.max",function(a){return s(a)?Math.max.apply(i,a):u(a)?Math.max.apply(i,K(a)):Math.max.apply(i,arguments)}); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() |
|||
30 | A("twig.functions.min",function(a){return s(a)?Math.min.apply(i,a):u(a)?Math.min.apply(i,K(a)):Math.min.apply(i,arguments)});A("twig.functions.random",function(a,b){return s(b)||t(b)?b[Math.floor(Math.random()*b.length)]:"number"==typeof b?Math.floor(Math.random()*b):b===i||"undefined"===typeof b?Math.floor(2147483647*Math.random()):""});A("twig.StringBuffer",I);I.prototype.append=I.prototype.append;I.prototype.toString=I.prototype.toString;A("twig.Environment",$);$.prototype.createTemplate=$.prototype.d; |
||
31 | $.prototype.filter=$.prototype.filter;$.prototype.invoke=$.prototype.w;$.prototype.test=$.prototype.test;$.prototype.escape=$.prototype.escape;$.prototype.macro=$.prototype.z;$.prototype.setFilter=$.prototype.F;$.prototype.setFunction=$.prototype.G;$.prototype.setTest=$.prototype.J;$.prototype.render=$.prototype.j;$.prototype.getGlobals=$.prototype.u;$.prototype.setGlobals=$.prototype.I;$.prototype.setGlobal=$.prototype.H;$.prototype.initRuntime=$.prototype.i;$.prototype.hasExtension=$.prototype.v; |
||
32 | $.prototype.getExtension=$.prototype.getExtension;$.prototype.addExtension=$.prototype.n;$.prototype.removeExtension=$.prototype.A;$.prototype.setExtensions=$.prototype.D;$.prototype.getExtensions=$.prototype.t;A("twig.Template",X);X.prototype.setTraits=X.prototype.K;X.prototype.setBlocks=X.prototype.C;X.prototype.getBlocks=X.prototype.s;X.prototype.renderParentBlock=X.prototype.B;X.prototype.renderBlock=X.prototype.k;X.prototype.callMacro=X.prototype.q;A("twig.Markup",Y);})(); |
||
33 |