Passed
Push — master ( 8ff2fc...2dab2b )
by P.R.
04:18 queued 10s
created

sdoc.sdoc2.node.UnknownNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 75.44 %

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 5
eloc 18
dl 43
loc 57
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A UnknownNode.is_block_command() 5 5 1
A UnknownNode.__init__() 9 9 1
A UnknownNode.is_phrasing() 5 5 1
A UnknownNode.get_command() 5 5 1
A UnknownNode.is_inline_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.styles import OutputStyle
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 UnknownNode(Node):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    """
11
    SDoc2 node for development testing.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def __init__(self, io: OutputStyle, 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 smile.
21
        :param str argument: Not used.
22
        """
23 1
        super().__init__(io, 'unknown', options, argument)
24
25
    # ------------------------------------------------------------------------------------------------------------------
26 1
    def get_command(self) -> str:
27
        """
28
        Returns the command of this node, i.e. unknown.
29
        """
30 1
        return 'unknown'
31
32
    # ------------------------------------------------------------------------------------------------------------------
33 1
    def is_block_command(self) -> bool:
34
        """
35
        Returns False.
36
        """
37 1
        return False
38
39
    # ------------------------------------------------------------------------------------------------------------------
40 1
    def is_inline_command(self) -> bool:
41
        """
42
        Returns True.
43
        """
44
        return False
45
46
    # ------------------------------------------------------------------------------------------------------------------
47 1
    def is_phrasing(self) -> bool:
48
        """
49
        Returns True.
50
        """
51 1
        return True
52
53
54
# ----------------------------------------------------------------------------------------------------------------------
55 1
NodeStore.register_block_command('unknown', UnknownNode)
56
NodeStore.register_inline_command('unknown', UnknownNode)
57