Completed
Push — master ( b95acc...a5fbcd )
by Oleksandr
01:06
created

Other   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Test Coverage

Coverage 90.91%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
dl 62
loc 62
ccs 10
cts 11
cp 0.9091
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B from_ini() 30 30 1

How to fix   Duplicated Code   

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:

1
# coding: utf-8
2
3 1
import zope.interface
4
5 1
from schematics.models import Model
6 1
from schematics.types import BooleanType, IntType
7
8 1
from .interfaces import INISerializable
9
10
11 1 View Code Duplication
@zope.interface.implementer(INISerializable)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12 1
class Other(Model):
13 1
    difficulty = IntType(
14
        min_value=0,
15
        default=193791,
16
        required=True,
17
    )
18 1
    display_custom_skins = BooleanType(
19
        default=True,
20
        required=True,
21
    )
22 1
    allow_custom_sounds = BooleanType(
23
        default=True,
24
        required=True,
25
    )
26 1
    filter_user_names = BooleanType(
27
        default=False,
28
        required=True,
29
    )
30 1
    small_way_point_labels = BooleanType(
31
        default=True,
32
        required=True,
33
    )
34 1
    skip_paratrooper_views = BooleanType(
35
        default=False,
36
        required=True,
37
    )
38 1
    new_clouds = BooleanType(
39
        default=True,
40
        required=True,
41
    )
42
43 1
    @classmethod
44
    def from_ini(cls, ini):
45
        return cls({
46
            'difficulty': ini.getint(
47
                'NET', 'difficulty',
48
                fallback=cls.difficulty.default,
49
            ),
50
            'display_custom_skins': ini.getboolean(
51
                'NET', 'SkinDownload',
52
                fallback=cls.display_custom_skins.default,
53
            ),
54
            'allow_custom_sounds': ini.getboolean(
55
                'NET', 'allowCustomSounds',
56
                fallback=cls.allow_custom_sounds.default,
57
            ),
58
            'filter_user_names': ini.getboolean(
59
                'NET', 'filterUserNames',
60
                fallback=cls.filter_user_names.default,
61
            ),
62
            'small_way_point_labels': ini.getboolean(
63
                'game', 'SmallMapWPLabels',
64
                fallback=cls.small_way_point_labels.default,
65
            ),
66
            'skip_paratrooper_views': ini.getboolean(
67
                'game', 'SkipParatrooperViews',
68
                fallback=cls.skip_paratrooper_views.default,
69
            ),
70
            'new_clouds': ini.getboolean(
71
                'game', 'TypeClouds',
72
                fallback=cls.new_clouds.default,
73
            ),
74
        })
75