| Total Complexity | 48 |
| Complexity/F | 5.33 |
| Lines of Code | 154 |
| Function Count | 9 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like rainloop/v/0.0.0/app/localization/moment/mr.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 | //! moment.js locale configuration |
||
| 6 | ;(function (global, factory) { |
||
| 7 | typeof exports === 'object' && typeof module !== 'undefined' |
||
| 8 | && typeof require === 'function' ? factory(require('../moment')) : |
||
| 9 | typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
||
| 10 | factory(global.moment) |
||
| 11 | }(this, function (moment) { 'use strict'; |
||
| 12 | |||
| 13 | |||
| 14 | var symbolMap = { |
||
| 15 | '1': '१', |
||
| 16 | '2': '२', |
||
| 17 | '3': '३', |
||
| 18 | '4': '४', |
||
| 19 | '5': '५', |
||
| 20 | '6': '६', |
||
| 21 | '7': '७', |
||
| 22 | '8': '८', |
||
| 23 | '9': '९', |
||
| 24 | '0': '०' |
||
| 25 | }, |
||
| 26 | numberMap = { |
||
| 27 | '१': '1', |
||
| 28 | '२': '2', |
||
| 29 | '३': '3', |
||
| 30 | '४': '4', |
||
| 31 | '५': '5', |
||
| 32 | '६': '6', |
||
| 33 | '७': '7', |
||
| 34 | '८': '8', |
||
| 35 | '९': '9', |
||
| 36 | '०': '0' |
||
| 37 | }; |
||
| 38 | |||
| 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 | |||
| 75 | var mr = moment.defineLocale('mr', { |
||
| 76 | months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'), |
||
| 77 | monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'), |
||
| 78 | monthsParseExact : true, |
||
| 79 | weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), |
||
| 80 | weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'), |
||
| 81 | weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'), |
||
| 82 | longDateFormat : { |
||
| 83 | LT : 'A h:mm वाजता', |
||
| 84 | LTS : 'A h:mm:ss वाजता', |
||
| 85 | L : 'DD/MM/YYYY', |
||
| 86 | LL : 'D MMMM YYYY', |
||
| 87 | LLL : 'D MMMM YYYY, A h:mm वाजता', |
||
| 88 | LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता' |
||
| 89 | }, |
||
| 90 | calendar : { |
||
| 91 | sameDay : '[आज] LT', |
||
| 92 | nextDay : '[उद्या] LT', |
||
| 93 | nextWeek : 'dddd, LT', |
||
| 94 | lastDay : '[काल] LT', |
||
| 95 | lastWeek: '[मागील] dddd, LT', |
||
| 96 | sameElse : 'L' |
||
| 97 | }, |
||
| 98 | relativeTime : { |
||
| 99 | future: '%sमध्ये', |
||
| 100 | past: '%sपूर्वी', |
||
| 101 | s: relativeTimeMr, |
||
| 102 | m: relativeTimeMr, |
||
| 103 | mm: relativeTimeMr, |
||
| 104 | h: relativeTimeMr, |
||
| 105 | hh: relativeTimeMr, |
||
| 106 | d: relativeTimeMr, |
||
| 107 | dd: relativeTimeMr, |
||
| 108 | M: relativeTimeMr, |
||
| 109 | MM: relativeTimeMr, |
||
| 110 | y: relativeTimeMr, |
||
| 111 | yy: relativeTimeMr |
||
| 112 | }, |
||
| 113 | preparse: function (string) { |
||
| 114 | return string.replace(/[१२३४५६७८९०]/g, function (match) { |
||
| 115 | return numberMap[match]; |
||
| 116 | }); |
||
| 117 | }, |
||
| 118 | postformat: function (string) { |
||
| 119 | return string.replace(/\d/g, function (match) { |
||
| 120 | return symbolMap[match]; |
||
| 121 | }); |
||
| 122 | }, |
||
| 123 | meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/, |
||
| 124 | meridiemHour : function (hour, meridiem) { |
||
| 125 | if (hour === 12) { |
||
| 126 | hour = 0; |
||
| 127 | } |
||
| 128 | if (meridiem === 'रात्री') { |
||
| 129 | return hour < 4 ? hour : hour + 12; |
||
| 130 | } else if (meridiem === 'सकाळी') { |
||
| 131 | return hour; |
||
| 132 | } else if (meridiem === 'दुपारी') { |
||
| 133 | return hour >= 10 ? hour : hour + 12; |
||
| 134 | } else if (meridiem === 'सायंकाळी') { |
||
| 135 | return hour + 12; |
||
| 136 | } |
||
| 137 | }, |
||
| 138 | meridiem: function (hour, minute, isLower) { |
||
| 139 | if (hour < 4) { |
||
| 140 | return 'रात्री'; |
||
| 141 | } else if (hour < 10) { |
||
| 142 | return 'सकाळी'; |
||
| 143 | } else if (hour < 17) { |
||
| 144 | return 'दुपारी'; |
||
| 145 | } else if (hour < 20) { |
||
| 146 | return 'सायंकाळी'; |
||
| 147 | } else { |
||
| 148 | return 'रात्री'; |
||
| 149 | } |
||
| 150 | }, |
||
| 151 | week : { |
||
| 152 | dow : 0, // Sunday is the first day of the week. |
||
| 153 | doy : 6 // The week that contains Jan 1st is the first week of the year. |
||
| 154 | } |
||
| 155 | }); |
||
| 156 | |||
| 157 | return mr; |
||
| 158 | |||
| 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.