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 Speedhack(Model): |
|
13 | 1 | check_server_time_speed = BooleanType( |
|
14 | default=True, |
||
15 | required=True, |
||
16 | ) |
||
17 | 1 | check_client_time_speed = BooleanType( |
|
18 | default=False, |
||
19 | required=True, |
||
20 | ) |
||
21 | 1 | max_time_difference = FloatType( |
|
22 | min_value=0.01, |
||
23 | default=0.2, |
||
24 | required=True, |
||
25 | ) |
||
26 | 1 | max_time_difference_period = FloatType( |
|
27 | min_value=1, |
||
28 | max_value=1000, |
||
29 | default=17, |
||
30 | required=True, |
||
31 | ) |
||
32 | |||
33 | 1 | @classmethod |
|
34 | def from_ini(cls, ini): |
||
35 | return cls({ |
||
36 | 'check_server_time_speed': ini.getboolean( |
||
37 | 'NET', 'checkServerTimeSpeed', |
||
38 | fallback=cls.check_server_time_speed.default, |
||
39 | ), |
||
40 | 'check_client_time_speed': ini.getboolean( |
||
41 | 'NET', 'checkClientTimeSpeed', |
||
42 | fallback=cls.check_client_time_speed.default, |
||
43 | ), |
||
44 | 'max_time_difference': ini.getfloat( |
||
45 | 'NET', 'checkTimeSpeedDifferense', |
||
46 | fallback=cls.max_time_difference.default, |
||
47 | ), |
||
48 | 'max_time_difference_period': ini.getfloat( |
||
49 | 'NET', 'checkTimeSpeedInterval', |
||
50 | fallback=cls.max_time_difference_period.default, |
||
51 | ), |
||
53 |