Total Complexity | 45 |
Complexity/F | 1.36 |
Lines of Code | 1 |
Function Count | 33 |
Duplicated Lines | 1 |
Ratio | 100 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like dist/helpers.js 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 | View Code Duplication | function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(t){return(e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function u(t,e,i){return(u=n()?Reflect.construct:function(t,e,n){var u=[null];u.push.apply(u,e);var i=new(Function.bind.apply(t,u));return n&&r(i,n.prototype),i}).apply(null,arguments)}function i(t){var n="function"==typeof Map?new Map:void 0;return(i=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,i)}function i(){return u(t,arguments,e(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,t)})(t)}var o=require("./modules/multisort.js"),s=require("./modules/multifilter.js"),f=require("./modules/multikey.js"),c=require("./modules/intersect.js"),l=require("./modules/min.js"),p=require("./modules/max.js"),a=require("./modules/diff.js"),y=require("./modules/unique.js"),m=require("./modules/summ.js"),h=require("./modules/average.js"),d=require("./modules/random.js"),g=require("./modules/getByKey.js"),j=require("./modules/first.js"),b=require("./modules/last.js");module.exports={Arr:function(e){var r,n;function u(){return e.apply(this,arguments)||this}n=e,(r=u).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n;var i,q,v,k=u.prototype;return k.multisort=function(t,e){return o(this[0],t,e)},k.multifilter=function(t,e,r){return s(this[0],t,e,r)},k.multikey=function(t){return f(this[0],t)},k.intersect=function(t,e){return c(this[0],t,e)},k.diff=function(t,e){return a(this[0],t,e)},k.pushIfNotExists=function(t){return this.indexOf(t)<0&&this.push(t),this.length},k.pushMultiple=function(t){return this.push.apply(this,t),this.length},k.pushMultipleIfNotExists=function(t){var e=this;return t.forEach(function(t){e.pushIfNotExists(t)}),e.length},k.getByKey=function(t,e){return g(this[0],t,e)},i=u,q=[{key:"unique",get:function(){return y(this[0])}},{key:"max",get:function(){return p(this[0])}},{key:"min",get:function(){return l(this[0])}},{key:"random",get:function(){return d(this)}},{key:"summ",get:function(){return m(this[0])}},{key:"average",get:function(){return h(this[0])}},{key:"first",get:function(){return j(this[0])}},{key:"last",get:function(){return b(this[0])}}],v=[{key:Symbol.species,get:function(){return Array}}],q&&t(i.prototype,q),v&&t(i,v),u}(i(Array)),multisort:o,multifilter:s,multikey:f,intersect:c,min:l,max:p,diff:a,unique:y,summ:m,average:h,random:d,getByKey:g,first:j,last:b}; |
|
2 | //# sourceMappingURL=helpers.js.map |
||
3 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.