sdoc.sdoc2.SDoc2Interpreter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 78.26 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 20
dl 36
loc 46
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SDoc2Interpreter.__init__() 7 7 1
A SDoc2Interpreter.process() 19 19 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
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:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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
47
# ----------------------------------------------------------------------------------------------------------------------
48