| Total Complexity | 2 |
| Total Lines | 46 |
| Duplicated Lines | 78.26 % |
| 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 | import antlr4 |
|
| 2 | 1 | from cleo.io.io import IO |
|
| 3 | |||
| 4 | 1 | from sdoc import sdoc2 |
|
| 5 | 1 | from sdoc.antlr.sdoc2Lexer import sdoc2Lexer |
|
| 6 | 1 | from sdoc.antlr.sdoc2Parser import sdoc2Parser |
|
| 7 | 1 | from sdoc.sdoc2.SDoc2Visitor import SDoc2Visitor |
|
| 8 | |||
| 9 | |||
| 10 | 1 | View Code Duplication | class SDoc2Interpreter: |
|
|
|||
| 11 | """ |
||
| 12 | Class for processing SDoc1 documents. |
||
| 13 | """ |
||
| 14 | |||
| 15 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 16 | 1 | def __init__(self, io: IO): |
|
| 17 | """ |
||
| 18 | Object constructor. |
||
| 19 | """ |
||
| 20 | |||
| 21 | 1 | self._io: IO = io |
|
| 22 | 1 | """ |
|
| 23 | Styled output formatter. |
||
| 24 | """ |
||
| 25 | |||
| 26 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 27 | 1 | def process(self, infile: str) -> int: |
|
| 28 | """ |
||
| 29 | Processes a SDoc1 document and returns the error count. |
||
| 30 | |||
| 31 | :param str infile: The input filename with the SDoc2 document. |
||
| 32 | """ |
||
| 33 | 1 | in_stream = antlr4.FileStream(infile, 'utf-8') |
|
| 34 | |||
| 35 | 1 | lexer = sdoc2Lexer(in_stream) |
|
| 36 | 1 | tokens = antlr4.CommonTokenStream(lexer) |
|
| 37 | 1 | parser = sdoc2Parser(tokens) |
|
| 38 | 1 | tree = parser.sdoc() |
|
| 39 | 1 | visitor = SDoc2Visitor(infile, self._io) |
|
| 40 | |||
| 41 | 1 | visitor.visit(tree) |
|
| 42 | |||
| 43 | 1 | sdoc2.node_store.prepare_content_tree() |
|
| 44 | |||
| 45 | 1 | return visitor.errors |
|
| 46 | |||
| 48 |