| Total Complexity | 2 |
| Total Lines | 39 |
| Duplicated Lines | 66.67 % |
| Coverage | 0% |
| Changes | 0 | ||
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): |
|
|
|
|||
| 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 |