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