Total Complexity | 3 |
Total Lines | 43 |
Duplicated Lines | 86.05 % |
Coverage | 100% |
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 | from abc import ABC |
|
2 | |||
3 | 1 | from cleo.commands.command import Command |
|
4 | |||
5 | |||
6 | 1 | View Code Duplication | class BaseCommand(Command, ABC): |
|
|||
7 | """ |
||
8 | Abstract parent command for all out commands. |
||
9 | """ |
||
10 | |||
11 | # ------------------------------------------------------------------------------------------------------------------ |
||
12 | 1 | def __set_style(self): |
|
13 | """ |
||
14 | Sets the output format style used by SDoc. |
||
15 | """ |
||
16 | # Style for file system objects (e.g. file and directory names). |
||
17 | 1 | self.add_style('fso', fg='green', options=['bold']) |
|
18 | |||
19 | # Style for errors. |
||
20 | 1 | self.add_style('error', fg='red', options=['bold']) |
|
21 | |||
22 | # Style for SDoc notices. |
||
23 | 1 | self.add_style('notice', fg='yellow') |
|
24 | |||
25 | # Style for titles. |
||
26 | 1 | self.add_style('title', fg='yellow') |
|
27 | |||
28 | # ------------------------------------------------------------------------------------------------------------------ |
||
29 | 1 | def _handle(self) -> int: |
|
30 | """ |
||
31 | Executes this command. |
||
32 | """ |
||
33 | raise NotImplementedError() |
||
34 | |||
35 | # ------------------------------------------------------------------------------------------------------------------ |
||
36 | 1 | def handle(self) -> int: |
|
37 | """ |
||
38 | Executes this command. |
||
39 | """ |
||
40 | 1 | self.__set_style() |
|
41 | |||
42 | 1 | return self._handle() |
|
43 | |||
45 |