Test Failed
Pull Request — master (#61)
by
unknown
11:24 queued 09:55
created

sdoc.command.BaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 84.09 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 17
dl 37
loc 44
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A BaseCommand.execute() 8 8 1
A BaseCommand.__set_style() 12 12 1
A BaseCommand.__init__() 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
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):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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
45
# ----------------------------------------------------------------------------------------------------------------------
46