sdoc.sdoc2.Position   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 92.45 %

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 49
loc 53
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Position.__init__() 31 31 1
A Position.__str__() 8 8 2

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 os
2
3
4 1 View Code Duplication
class Position:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5
    """
6
    Class for start and end position of a node in a SDoc source file.
7
    """
8
9
    # ------------------------------------------------------------------------------------------------------------------
10 1
    def __init__(self, file_name: str, start_line: int, start_column: int, end_line: int, end_column: int):
11
        """
12
        Object constructor.
13
14
        :param str file_name: The name of the file where the node is defined.
15
        :param int start_line: The line where the node definition starts.
16
        :param int start_column: The column where the node definition starts.
17
        :param int end_line: The line where the node definition ends.
18
        :param int end_column: The column where the node definition end.
19
        """
20 1
        self.file_name: str = file_name
21
        """
22
        The name of the file where the node is defined.
23
        """
24
25 1
        self.start_line: int = start_line
26
        """
27
        The line where the node definition starts.
28
        """
29
30 1
        self.start_column: int = start_column
31
        """
32
        The column where the node definition starts.
33
        """
34
35 1
        self.end_line: int = end_line
36
        """
37
        The line where the node definition ends.
38
        """
39 1
        self.end_column: int = end_column
40 1
        """
41
        The column where the node definition end.
42
        """
43
44
    # ------------------------------------------------------------------------------------------------------------------
45 1
    def __str__(self) -> str:
46
        """
47
        String representation of the position.
48
        """
49 1
        if not self.file_name:
50
            return "{0:d}.{1:d}".format(self.start_line, self.start_column + 1)
51
52 1
        return "{0!s}:{1:d}.{2:d}".format(os.path.relpath(self.file_name), self.start_line, self.start_column + 1)
53
54
# ----------------------------------------------------------------------------------------------------------------------
55