Total Complexity | 3 |
Total Lines | 43 |
Duplicated Lines | 67.44 % |
Coverage | 100% |
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 | 1 | from typing import Dict |
|
2 | |||
3 | 1 | from cleo.io.io import IO |
|
4 | |||
5 | 1 | from sdoc.sdoc2.node.HeadingNode import HeadingNode |
|
6 | 1 | from sdoc.sdoc2.NodeStore import NodeStore |
|
7 | |||
8 | |||
9 | 1 | View Code Duplication | class Sub2SectionNode(HeadingNode): |
|
|||
10 | """ |
||
11 | SDoc2 node for sub-subsections. |
||
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 section. |
||
21 | :param str argument: The title of this section. |
||
22 | """ |
||
23 | 1 | super().__init__(io, 'sub2section', options, argument) |
|
24 | |||
25 | # ------------------------------------------------------------------------------------------------------------------ |
||
26 | 1 | def get_command(self) -> str: |
|
27 | """ |
||
28 | Returns the command of this node, i.e. sub2section. |
||
29 | """ |
||
30 | 1 | return 'sub2section' |
|
31 | |||
32 | # ------------------------------------------------------------------------------------------------------------------ |
||
33 | 1 | def get_hierarchy_level(self, parent_hierarchy_level: int = -1) -> int: |
|
34 | """ |
||
35 | Returns 4. |
||
36 | """ |
||
37 | 1 | return 4 |
|
38 | |||
39 | |||
40 | # ---------------------------------------------------------------------------------------------------------------------- |
||
41 | 1 | NodeStore.register_inline_command('sub2section', Sub2SectionNode) |
|
42 | NodeStore.register_inline_command('subsubsection', Sub2SectionNode) |
||
43 |