Completed
Push — master ( 9d3bc0...b059cb )
by Oleksandr
01:07
created

Anticheat   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Test Coverage

Coverage 80%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 2
c 3
b 0
f 1
dl 35
loc 35
ccs 8
cts 10
cp 0.8
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A default() 6 6 1
A from_ini() 9 9 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 IntType
7 1
from schematics.types.compound import ModelType
8
9 1
from ..interfaces import INISerializable, DefaultProvider
10 1
from ..helpers import field_from_ini
11 1
from .lags import Lags
12 1
from .speedhack import Speedhack
13
14
15 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...
16 1
@zope.interface.implementer(DefaultProvider)
17 1
class Anticheat(Model):
18 1
    version_check_level = IntType(
19
        min_value=0,
20
        max_value=2,
21
        default=0,
22
        required=True,
23
    )
24 1
    lags = ModelType(
25
        model_spec=Lags,
26
        required=True,
27
    )
28 1
    speedhack = ModelType(
29
        model_spec=Speedhack,
30
        required=True,
31
    )
32
33 1
    @classmethod
34
    def from_ini(cls, ini):
35
        return cls({
36
            'version_check_level': field_from_ini(
37
                cls.version_check_level, ini,
38
                'NET', 'checkRuntime',
39
            ),
40
            'lags': Lags.from_ini(ini),
41
            'speedhack': Speedhack.from_ini(ini),
42
        })
43
44 1
    @classmethod
45
    def default(cls):
46
        return cls({
47
            'version_check_level': cls.version_check_level.default,
48
            'lags': Lags.default(),
49
            'speedhack': Speedhack.default(),
50
        })
51