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

rules.go   A

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 6
eloc 14
dl 0
loc 17
ccs 1
cts 1
cp 1
crap 6
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B timeago.getRules 0 13 6
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