| Conditions | 24 |
| Paths | 24 |
| Total Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like mr.js ➔ ... ➔ relativeTimeMr 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 | //! moment.js locale configuration |
||
| 39 | function relativeTimeMr(number, withoutSuffix, string, isFuture) |
||
|
|
|||
| 40 | { |
||
| 41 | var output = ''; |
||
| 42 | if (withoutSuffix) { |
||
| 43 | switch (string) { |
||
|
1 ignored issue
–
show
|
|||
| 44 | case 's': output = 'काही सेकंद'; break; |
||
| 45 | case 'm': output = 'एक मिनिट'; break; |
||
| 46 | case 'mm': output = '%d मिनिटे'; break; |
||
| 47 | case 'h': output = 'एक तास'; break; |
||
| 48 | case 'hh': output = '%d तास'; break; |
||
| 49 | case 'd': output = 'एक दिवस'; break; |
||
| 50 | case 'dd': output = '%d दिवस'; break; |
||
| 51 | case 'M': output = 'एक महिना'; break; |
||
| 52 | case 'MM': output = '%d महिने'; break; |
||
| 53 | case 'y': output = 'एक वर्ष'; break; |
||
| 54 | case 'yy': output = '%d वर्षे'; break; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | else { |
||
| 58 | switch (string) { |
||
|
1 ignored issue
–
show
|
|||
| 59 | case 's': output = 'काही सेकंदां'; break; |
||
| 60 | case 'm': output = 'एका मिनिटा'; break; |
||
| 61 | case 'mm': output = '%d मिनिटां'; break; |
||
| 62 | case 'h': output = 'एका तासा'; break; |
||
| 63 | case 'hh': output = '%d तासां'; break; |
||
| 64 | case 'd': output = 'एका दिवसा'; break; |
||
| 65 | case 'dd': output = '%d दिवसां'; break; |
||
| 66 | case 'M': output = 'एका महिन्या'; break; |
||
| 67 | case 'MM': output = '%d महिन्यां'; break; |
||
| 68 | case 'y': output = 'एका वर्षा'; break; |
||
| 69 | case 'yy': output = '%d वर्षां'; break; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | return output.replace(/%d/i, number); |
||
| 73 | } |
||
| 74 | |||
| 159 | })); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.