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

sdoc.sdoc2.formatter.html.SmileHtmlFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 66.67 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 26
loc 39
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SmileHtmlFormatter.generate() 10 10 1
A SmileHtmlFormatter.get_html() 8 8 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 Any
2
3
from sdoc.helper.Html import Html
4
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
5
from sdoc.sdoc2.node.SmileNode import SmileNode
6
from sdoc.sdoc2.NodeStore import NodeStore
7
8
9 View Code Duplication
class SmileHtmlFormatter(HtmlFormatter):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    """
11
    HtmlFormatter for generating HTML code for smile.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15
    def generate(self, node: SmileNode, file: Any) -> None:
16
        """
17
        Generates the HTML code for a smile node.
18
19
        :param SmileNode node: The smile node.
20
        :param any file: The output file.
21
        """
22
        file.write(SmileHtmlFormatter.get_html())
23
24
        HtmlFormatter.generate(self, node, file)
25
26
    # ------------------------------------------------------------------------------------------------------------------
27
    @staticmethod
28
    def get_html() -> str:
29
        """
30
        Returns string with generated HTML tag for smile.
31
32
        :rtype: str
33
        """
34
        return Html.generate_element('b', {}, 'SMILE')
35
36
37
# ----------------------------------------------------------------------------------------------------------------------
38
NodeStore.register_formatter('smile', 'html', SmileHtmlFormatter)
39