Total Complexity | 3 |
Total Lines | 20 |
Duplicated Lines | 50 % |
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 | """ |
||
2 | BasicNeeds - useful functions library |
||
3 | |||
4 | This library has functions useful to keep main logic short and simple |
||
5 | """ |
||
6 | # standard Python packages |
||
7 | from datetime import datetime, timezone |
||
8 | |||
9 | |||
10 | View Code Duplication | class BasicNeeds: |
|
|
|||
11 | |||
12 | def fn_optional_print(self, boolean_variable, string_to_print): |
||
13 | if boolean_variable: |
||
14 | self.fn_timestamped_print(self, string_to_print) |
||
15 | |||
16 | @staticmethod |
||
17 | def fn_timestamped_print(self, string_to_print): |
||
18 | print(datetime.now(timezone.utc).strftime("%Y-%b-%d %H:%M:%S.%f %Z") |
||
19 | + ' - ' + string_to_print) |
||
20 |