sdoc.sdoc2.formatter.html.ItemHtmlFormatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 59.38 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 14
dl 19
loc 32
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ItemHtmlFormatter.generate() 13 13 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 Any
2
3 1
from sdoc.helper.Html import Html
4 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
5 1
from sdoc.sdoc2.node.ItemNode import ItemNode
6 1
from sdoc.sdoc2.NodeStore import NodeStore
7
8
9 1 View Code Duplication
class ItemHtmlFormatter(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 items.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def generate(self, node: ItemNode, file: Any) -> None:
16
        """
17
        Generates the HTML code for an item node.
18
19
        :param ItemNode node: The item node.
20
        :param any file: The output file.
21
        """
22 1
        attributes = {'id': node.get_option_value('id')}
23
24 1
        file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id'])))
25 1
        node.prepare_content_tree()
26 1
        HtmlFormatter.generate(self, node, file)
27 1
        file.write('</li>')
28
29
30
# ----------------------------------------------------------------------------------------------------------------------
31
NodeStore.register_formatter('item', 'html', ItemHtmlFormatter)
32