Total Complexity | 6 |
Total Lines | 29 |
Duplicated Lines | 100 % |
Coverage | 94.74% |
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 | ''' |
||
7000 | 1 | View Code Duplication | class LiteralOperand(FrozenClass): |
7001 | ''' |
||
7002 | :ivar Value: |
||
7003 | :vartype Value: Variant |
||
7004 | ''' |
||
7005 | 1 | def __init__(self, binary=None): |
|
7006 | 1 | if binary is not None: |
|
7007 | 1 | self._binary_init(binary) |
|
7008 | 1 | self._freeze = True |
|
7009 | 1 | return |
|
7010 | 1 | self.Value = Variant() |
|
7011 | 1 | self._freeze = True |
|
7012 | |||
7013 | 1 | def to_binary(self): |
|
7014 | 1 | packet = [] |
|
7015 | 1 | packet.append(self.Value.to_binary()) |
|
7016 | 1 | return b''.join(packet) |
|
7017 | |||
7018 | 1 | @staticmethod |
|
7019 | def from_binary(data): |
||
7020 | 1 | return LiteralOperand(data) |
|
7021 | |||
7022 | 1 | def _binary_init(self, data): |
|
7023 | 1 | self.Value = Variant.from_binary(data) |
|
7024 | |||
7025 | 1 | def __str__(self): |
|
7026 | return 'LiteralOperand(' + 'Value:' + str(self.Value) + ')' |
||
7027 | |||
7028 | 1 | __repr__ = __str__ |
|
7029 | |||
14349 |