| Conditions | 12 |
| Paths | 24 |
| Total Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like sourceAttr.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 | |||
| 25 | Array.prototype.forEach.call(params.value, (v) => { |
||
| 26 | var item = v |
||
| 27 | try { |
||
| 28 | var displayV = eval('item.' + params.display) |
||
| 29 | if(typeof params.display !== 'undefined' && params.display !== null |
||
| 30 | && typeof displayV !== 'undefined' && displayV !== null) { |
||
| 31 | item = displayV |
||
| 32 | }else { |
||
| 33 | if(typeof v === 'string') { |
||
| 34 | item = v |
||
| 35 | }else { |
||
| 36 | item = v[Object.keys(v)[0]] |
||
| 37 | } |
||
| 38 | } |
||
| 39 | }catch(e) { |
||
| 40 | item = v[Object.keys(v)[0]] |
||
| 41 | } |
||
| 42 | |||
| 43 | if(typeof val === 'object' && Object.prototype.toString.call(val) === '[object Array]' |
||
| 44 | && typeof item === 'object' && Object.prototype.toString.call(item) === '[object Array]') { |
||
| 45 | |||
| 46 | Array.prototype.forEach.call(item, (i) => { |
||
| 47 | if(val.includes(i)) { |
||
| 48 | selected = 'selected="selected"' |
||
| 49 | } |
||
| 50 | }) |
||
| 51 | }else if(val === item) { |
||
| 52 | selected = 'selected="selected"' |
||
| 53 | } |
||
| 54 | }) |
||
| 55 | }else if(params.value === hiddenVal) { |
||
| 65 |