Passed
Push — master ( 609cd5...21ac6e )
by Serhii
02:43 queued 01:11
created

timeago.getRules   B

Complexity

Conditions 6

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 12
dl 0
loc 13
ccs 1
cts 1
cp 1
crap 6
rs 8.6666
c 0
b 0
f 0
nop 2
1
package timeago
2
3
import "github.com/SerhiiCho/timeago/models"
4
5
func getRules(number, lastDigit int) map[string]models.Rule {
6 1
	return map[string]models.Rule{
7
		"en": {
8
			Single: number == 1,
9
			Plural: number > 1 || number == 0,
10
		},
11
		"ru": {
12
			Single: lastDigit == 1 || number == 0,
13
			Plural: lastDigit >= 2 && lastDigit < 5,
14
			Special: []bool{
15
				number >= 5 && number <= 20,
16
				lastDigit == 0,
17
				lastDigit >= 5 && lastDigit <= 9,
18
			},
19
		},
20
	}
21
}
22