sdoc.sdoc2.node.CaptionNode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 73.47 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 36
loc 49
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A CaptionNode.get_command() 5 5 1
A CaptionNode.__init__() 9 9 1
A CaptionNode.is_inline_command() 5 5 1
A CaptionNode.is_block_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 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 CaptionNode(Node):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    """
11
    SDoc2 node for captions.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def __init__(self, io: IO, options: Dict[str, str], argument: str):
16
        """
17
        Object constructor.
18
19
        :param OutputStyle io: The IO object.
20
        :param dict[str,str] options: The options of this caption.
21
        :param str argument: The title of this caption.
22
        """
23
        super().__init__(io, 'caption', options, argument)
24
25
    # ------------------------------------------------------------------------------------------------------------------
26 1
    def get_command(self) -> str:
27
        """
28
        Returns the command of this node, i.e. caption.
29
        """
30
        return 'caption'
31
32
    # ------------------------------------------------------------------------------------------------------------------
33 1
    def is_block_command(self) -> bool:
34
        """
35
        Returns False.
36
        """
37
        return False
38
39
    # ------------------------------------------------------------------------------------------------------------------
40 1
    def is_inline_command(self) -> bool:
41
        """
42
        Returns True.
43
        """
44
        return True
45
46
47
# ----------------------------------------------------------------------------------------------------------------------
48
NodeStore.register_inline_command('caption', CaptionNode)
49