Passed
Push — master ( 4cb748...589c2a )
by P.R.
01:36
created

sdoc.command.BaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 86.05 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 37
loc 43
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A BaseCommand.__set_style() 15 15 1
A BaseCommand._handle() 5 5 1
A BaseCommand.handle() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

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):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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
44
# ----------------------------------------------------------------------------------------------------------------------
45