formio/node_modules/moment/locale/sl.js   F
last analyzed

Complexity

Total Complexity 106
Complexity/F 21.2

Size

Lines of Code 170
Function Count 5

Duplication

Duplicated Lines 170
Ratio 100 %

Importance

Changes 0
Metric Value
cc 0
wmc 106
nc 0
mnd 5
bc 28
fnc 5
dl 170
loc 170
rs 1.5789
bpm 5.6
cpm 21.2
noi 6
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B sl.js ➔ ?!? 165 165 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

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:

Complexity

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like formio/node_modules/moment/locale/sl.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
2
//! locale : Slovenian [sl]
3
//! author : Robert Sedovšek : https://github.com/sedovsek
4
5 View Code Duplication
;(function (global, factory) {
6
   typeof exports === 'object' && typeof module !== 'undefined'
7
       && typeof require === 'function' ? factory(require('../moment')) :
8
   typeof define === 'function' && define.amd ? define(['../moment'], factory) :
9
   factory(global.moment)
10
}(this, (function (moment) { 'use strict';
11
12
13
function processRelativeTime(number, withoutSuffix, key, isFuture) {
14
    var result = number + ' ';
15
    switch (key) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
16
        case 's':
17
            return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
18
        case 'ss':
19
            if (number === 1) {
20
                result += withoutSuffix ? 'sekundo' : 'sekundi';
21
            } else if (number === 2) {
22
                result += withoutSuffix || isFuture ? 'sekundi' : 'sekundah';
23
            } else if (number < 5) {
24
                result += withoutSuffix || isFuture ? 'sekunde' : 'sekundah';
25
            } else {
26
                result += withoutSuffix || isFuture ? 'sekund' : 'sekund';
27
            }
28
            return result;
29
        case 'm':
30
            return withoutSuffix ? 'ena minuta' : 'eno minuto';
31
        case 'mm':
32
            if (number === 1) {
33
                result += withoutSuffix ? 'minuta' : 'minuto';
34
            } else if (number === 2) {
35
                result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
36
            } else if (number < 5) {
37
                result += withoutSuffix || isFuture ? 'minute' : 'minutami';
38
            } else {
39
                result += withoutSuffix || isFuture ? 'minut' : 'minutami';
40
            }
41
            return result;
42
        case 'h':
43
            return withoutSuffix ? 'ena ura' : 'eno uro';
44
        case 'hh':
45
            if (number === 1) {
46
                result += withoutSuffix ? 'ura' : 'uro';
47
            } else if (number === 2) {
48
                result += withoutSuffix || isFuture ? 'uri' : 'urama';
49
            } else if (number < 5) {
50
                result += withoutSuffix || isFuture ? 'ure' : 'urami';
51
            } else {
52
                result += withoutSuffix || isFuture ? 'ur' : 'urami';
53
            }
54
            return result;
55
        case 'd':
56
            return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
57
        case 'dd':
58
            if (number === 1) {
59
                result += withoutSuffix || isFuture ? 'dan' : 'dnem';
60
            } else if (number === 2) {
61
                result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
62
            } else {
63
                result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
64
            }
65
            return result;
66
        case 'M':
67
            return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
68
        case 'MM':
69
            if (number === 1) {
70
                result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
71
            } else if (number === 2) {
72
                result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
73
            } else if (number < 5) {
74
                result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
75
            } else {
76
                result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
77
            }
78
            return result;
79
        case 'y':
80
            return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
81
        case 'yy':
82
            if (number === 1) {
83
                result += withoutSuffix || isFuture ? 'leto' : 'letom';
84
            } else if (number === 2) {
85
                result += withoutSuffix || isFuture ? 'leti' : 'letoma';
86
            } else if (number < 5) {
87
                result += withoutSuffix || isFuture ? 'leta' : 'leti';
88
            } else {
89
                result += withoutSuffix || isFuture ? 'let' : 'leti';
90
            }
91
            return result;
92
    }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
93
}
94
95
var sl = moment.defineLocale('sl', {
96
    months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
97
    monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
98
    monthsParseExact: true,
99
    weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
100
    weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
101
    weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
102
    weekdaysParseExact : true,
103
    longDateFormat : {
104
        LT : 'H:mm',
105
        LTS : 'H:mm:ss',
106
        L : 'DD.MM.YYYY',
107
        LL : 'D. MMMM YYYY',
108
        LLL : 'D. MMMM YYYY H:mm',
109
        LLLL : 'dddd, D. MMMM YYYY H:mm'
110
    },
111
    calendar : {
112
        sameDay  : '[danes ob] LT',
113
        nextDay  : '[jutri ob] LT',
114
115
        nextWeek : function () {
116
            switch (this.day()) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
117
                case 0:
118
                    return '[v] [nedeljo] [ob] LT';
119
                case 3:
120
                    return '[v] [sredo] [ob] LT';
121
                case 6:
122
                    return '[v] [soboto] [ob] LT';
123
                case 1:
124
                case 2:
125
                case 4:
126
                case 5:
127
                    return '[v] dddd [ob] LT';
128
            }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
129
        },
130
        lastDay  : '[včeraj ob] LT',
131
        lastWeek : function () {
132
            switch (this.day()) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
133
                case 0:
134
                    return '[prejšnjo] [nedeljo] [ob] LT';
135
                case 3:
136
                    return '[prejšnjo] [sredo] [ob] LT';
137
                case 6:
138
                    return '[prejšnjo] [soboto] [ob] LT';
139
                case 1:
140
                case 2:
141
                case 4:
142
                case 5:
143
                    return '[prejšnji] dddd [ob] LT';
144
            }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
145
        },
146
        sameElse : 'L'
147
    },
148
    relativeTime : {
149
        future : 'čez %s',
150
        past   : 'pred %s',
151
        s      : processRelativeTime,
152
        ss     : processRelativeTime,
153
        m      : processRelativeTime,
154
        mm     : processRelativeTime,
155
        h      : processRelativeTime,
156
        hh     : processRelativeTime,
157
        d      : processRelativeTime,
158
        dd     : processRelativeTime,
159
        M      : processRelativeTime,
160
        MM     : processRelativeTime,
161
        y      : processRelativeTime,
162
        yy     : processRelativeTime
163
    },
164
    dayOfMonthOrdinalParse: /\d{1,2}\./,
165
    ordinal : '%d.',
166
    week : {
167
        dow : 1, // Monday is the first day of the week.
168
        doy : 7  // The week that contains Jan 1st is the first week of the year.
169
    }
170
});
171
172
return sl;
173
174
})));
175