sdoc.sdoc2.node.EndParagraphNode   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 78.69 %

Test Coverage

Coverage 81.25%

Importance

Changes 0
Metric Value
wmc 5
eloc 17
dl 48
loc 61
ccs 13
cts 16
cp 0.8125
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A EndParagraphNode.is_block_command() 5 5 1
A EndParagraphNode.get_command() 7 7 1
A EndParagraphNode.__init__() 9 9 1
A EndParagraphNode.is_inline_command() 5 5 1
A EndParagraphNode.prepare_content_tree() 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 1
from typing import Dict
2
3 1
from cleo.io.io import IO
4
5 1
from sdoc.sdoc2.node.Node import Node
6 1
from sdoc.sdoc2.NodeStore import NodeStore
7
8
9 1 View Code Duplication
class EndParagraphNode(Node):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    """
11
    SDoc2 node for end of paragraphs.
12
13
    Note: End of paragraphs will are temporary used during the content tree preparation. Before and after the content
14
          preparation end of paragraph nodes do not exist.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18 1
    def __init__(self, io: IO, options: Dict[str, str], argument: str):
19
        """
20
        Object constructor.
21
22
        :param OutputStyle io: The IO object.
23
        :param dict[str,str] options: Not used.
24
        :param str argument: Not used.
25
        """
26 1
        super().__init__(io, 'end_paragraph', options, argument)
27
28
    # ------------------------------------------------------------------------------------------------------------------
29 1
    def get_command(self) -> str:
30
        """
31
        Returns the command of this node, i.e. end_paragraph.
32
33
        :rtype: str
34
        """
35 1
        return 'end_paragraph'
36
37
    # ------------------------------------------------------------------------------------------------------------------
38 1
    def is_block_command(self) -> bool:
39
        """
40
        Returns False.
41
        """
42
        return False
43
44
    # ------------------------------------------------------------------------------------------------------------------
45 1
    def is_inline_command(self) -> bool:
46
        """
47
        Returns False.
48
        """
49
        return False
50
51
    # ------------------------------------------------------------------------------------------------------------------
52 1
    def prepare_content_tree(self) -> None:
53
        """
54
        Not implemented for end paragraph nodes.
55
        """
56
        raise RuntimeError()
57
58
59
# ----------------------------------------------------------------------------------------------------------------------
60
NodeStore.register_inline_command('end_paragraph', EndParagraphNode)
61