Passed
Push — master ( 58c7cb...3aad29 )
by Serhii
03:52 queued 02:07
created

config.go   A

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
cc 5
eloc 22
dl 0
loc 37
rs 10
c 0
b 0
f 0
ccs 5
cts 6
cp 0.8333
crap 5.1158

4 Methods

Rating   Name   Duplication   Size   Complexity  
A timeago.locationIsSet 0 2 1
A timeago.SetConfig 0 6 2
A timeago.translationsAreSet 0 2 1
A timeago.locationIsNotSet 0 2 1
1
package timeago
2
3
type Translation struct {
4
	Language     string
5
	Translations map[string]string
6
}
7
8
type Config struct {
9
	Language     string
10
	Location     string
11
	Translations []Translation
12
}
13
14
var config = Config{
15
	Language:     "en",
16
	Location:     "",
17
	Translations: []Translation{},
18
}
19
20
func SetConfig(conf Config) {
21 1
	if conf.Language == "" {
22 1
		conf.Language = config.Language
23
	}
24
25 1
	config = conf
26
}
27
28
func locationIsSet() bool {
29 1
	return config.Location != ""
30
}
31
32
func locationIsNotSet() bool {
33
	return !locationIsSet()
34
}
35
36
func translationsAreSet() bool {
37 1
	return len(config.Translations) > 0
38
}
39