| Total Complexity | 4 |
| Total Lines | 63 |
| Duplicated Lines | 90.48 % |
| Coverage | 93.75% |
| Changes | 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 | 1 | import abc |
|
| 2 | |||
| 3 | 1 | from etlt.condition.Condition import Condition |
|
| 4 | |||
| 5 | |||
| 6 | 1 | View Code Duplication | class SimpleCondition(Condition): |
|
|
|||
| 7 | """ |
||
| 8 | A simple condition matches a single field in the row against an expression. |
||
| 9 | """ |
||
| 10 | |||
| 11 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 12 | 1 | def __init__(self, field, expression): |
|
| 13 | """ |
||
| 14 | Object contructor. |
||
| 15 | |||
| 16 | :param str field: The name of the field in the row that must be match against the expression. |
||
| 17 | :param str expression: The expression. |
||
| 18 | """ |
||
| 19 | 1 | self._field = field |
|
| 20 | """ |
||
| 21 | The name of the field in the row that must be match against the expression. |
||
| 22 | |||
| 23 | :type: str |
||
| 24 | """ |
||
| 25 | |||
| 26 | 1 | self._expression = expression |
|
| 27 | 1 | """ |
|
| 28 | The expression. |
||
| 29 | |||
| 30 | :type: str |
||
| 31 | """ |
||
| 32 | |||
| 33 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 34 | 1 | @property |
|
| 35 | 1 | def expression(self): |
|
| 36 | """ |
||
| 37 | Returns the expression. |
||
| 38 | |||
| 39 | :rtype: str |
||
| 40 | """ |
||
| 41 | 1 | return self._expression |
|
| 42 | |||
| 43 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 44 | 1 | @property |
|
| 45 | 1 | def field(self): |
|
| 46 | """ |
||
| 47 | Returns the name of the field in the row that must be match against the expression. |
||
| 48 | |||
| 49 | :rtype: str |
||
| 50 | """ |
||
| 51 | return self._field |
||
| 52 | |||
| 53 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 54 | 1 | @property |
|
| 55 | 1 | @abc.abstractmethod |
|
| 56 | 1 | def scheme(self): |
|
| 57 | """ |
||
| 58 | Returns the scheme of the simple condition. |
||
| 59 | |||
| 60 | :rtype: str |
||
| 61 | """ |
||
| 62 | raise NotImplementedError() |
||
| 63 | |||
| 65 |