Total Complexity | 1 |
Total Lines | 40 |
Duplicated Lines | 100 % |
Coverage | 87.5% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
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 |
||
11 | 1 | View Code Duplication | @zope.interface.implementer(INISerializable) |
|
|||
12 | 1 | class Refly(Model): |
|
13 | 1 | is_disabled = BooleanType( |
|
14 | default=False, |
||
15 | required=True, |
||
16 | ) |
||
17 | 1 | kia_delay = IntType( |
|
18 | min_value=0, |
||
19 | default=0, |
||
20 | required=True, |
||
21 | ) |
||
22 | 1 | kia_delay_multiplier = FloatType( |
|
23 | min_value=0.0, |
||
24 | default=0.0, |
||
25 | required=True, |
||
26 | ) |
||
27 | 1 | max_kia = IntType( |
|
28 | min_value=-1, |
||
29 | default=-1, |
||
30 | required=True, |
||
31 | ) |
||
32 | |||
33 | 1 | @classmethod |
|
34 | def from_ini(cls, ini): |
||
35 | return cls({ |
||
36 | 'is_disabled': ini.getboolean( |
||
37 | 'NET', 'reflyDisabled', |
||
38 | fallback=cls.is_disabled.default, |
||
39 | ), |
||
40 | 'kia_delay': ini.getint( |
||
41 | 'NET', 'reflyKIADelay', |
||
42 | fallback=cls.kia_delay.default, |
||
43 | ), |
||
44 | 'kia_delay_multiplier': ini.getfloat( |
||
45 | 'NET', 'reflyKIADelayMultiplier', |
||
46 | fallback=cls.kia_delay_multiplier.default, |
||
47 | ), |
||
48 | 'max_kia': ini.getint( |
||
49 | 'NET', 'maxAllowedKIA', |
||
50 | fallback=cls.max_kia.default, |
||
51 | ), |
||
53 |