Test Failed
Push — master ( 714282...4cb748 )
by P.R.
01:55 queued 13s
created

sdoc.sdoc2.node.IconDefNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 76.67 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 20
dl 46
loc 60
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A IconDefNode.__init__() 9 9 1
A IconDefNode.is_block_command() 5 5 1
A IconDefNode.prepare_content_tree() 8 8 1
A IconDefNode.is_inline_command() 5 5 1
A IconDefNode.get_command() 5 5 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 typing import Dict
2
3
from cleo.styles import OutputStyle
4
5
from sdoc.sdoc2.node.IconNode import IconNode
6
from sdoc.sdoc2.node.Node import Node
7
from sdoc.sdoc2.NodeStore import NodeStore
8
9
10 View Code Duplication
class IconDefNode(Node):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
    """
12
    The class for definition of icons in sdoc2.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16
    def __init__(self, io: OutputStyle, options: Dict[str, str], argument: str):
17
        """
18
        Object constructor.
19
20
        :param OutputStyle io: The IO object.
21
        :param dict[str,str] options: The options of this figure.
22
        :param str argument: Not used.
23
        """
24
        super().__init__(io, 'icon_def', options, argument)
25
26
    # ------------------------------------------------------------------------------------------------------------------
27
    def get_command(self) -> str:
28
        """
29
        Returns the command of this node, i.e. icondef.
30
        """
31
        return 'icondef'
32
33
    # ------------------------------------------------------------------------------------------------------------------
34
    def is_block_command(self) -> bool:
35
        """
36
        Returns False.
37
        """
38
        return False
39
40
    # ------------------------------------------------------------------------------------------------------------------
41
    def is_inline_command(self) -> bool:
42
        """
43
        Returns True.
44
        """
45
        return True
46
47
    # ------------------------------------------------------------------------------------------------------------------
48
    def prepare_content_tree(self) -> None:
49
        """
50
        Prepares this node for further processing.
51
        """
52
        reference_name = self.argument
53
        attributes = self._options
54
55
        IconNode.add_definition(reference_name, attributes)
56
57
58
# ----------------------------------------------------------------------------------------------------------------------
59
NodeStore.register_inline_command('icondef', IconDefNode)
60