Total Complexity | 3 |
Total Lines | 44 |
Duplicated Lines | 84.09 % |
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 import Command |
|
4 | 1 | from cleo.styles import CleoStyle |
|
5 | |||
6 | |||
7 | 1 | View Code Duplication | class BaseCommand(Command, ABC): |
|
|||
8 | """ |
||
9 | Abstract parent command for all out commands. |
||
10 | """ |
||
11 | |||
12 | # ------------------------------------------------------------------------------------------------------------------ |
||
13 | 1 | def __init__(self, name=None): |
|
14 | """ |
||
15 | Object constructor. |
||
16 | |||
17 | :param str|None name: The name of the command. |
||
18 | """ |
||
19 | 1 | Command.__init__(self, name) |
|
20 | |||
21 | # ------------------------------------------------------------------------------------------------------------------ |
||
22 | 1 | def __set_style(self): |
|
23 | """ |
||
24 | Sets the output format style used by SDoc. |
||
25 | """ |
||
26 | # Style for file system objects (e.g. file and directory names). |
||
27 | 1 | self.set_style('fso', fg='green', options=['bold']) |
|
28 | |||
29 | # Style for errors. |
||
30 | 1 | self.set_style('error', fg='red', options=['bold']) |
|
31 | |||
32 | # Style for SDoc1 notices. |
||
33 | 1 | self.set_style('notice', fg='yellow') |
|
34 | |||
35 | # ------------------------------------------------------------------------------------------------------------------ |
||
36 | 1 | def execute(self, i, o): |
|
37 | 1 | self.input = i |
|
38 | 1 | self.output = o |
|
39 | |||
40 | 1 | self.__set_style() |
|
41 | 1 | self.output = CleoStyle(self.input, self.output) |
|
42 | |||
43 | 1 | return self.handle() |
|
44 | |||
46 |