Failed Conditions
Pull Request — master (#2076)
by Abdeali
02:04
created

SourcePosition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 17 1
A file() 0 3 1
A __json__() 0 5 2
1
from os.path import relpath, abspath
2
3
from coalib.misc.Decorators import (
4
    enforce_signature, generate_ordering, generate_repr, get_public_members)
5
from coalib.results.TextPosition import TextPosition
6
7
8
@generate_repr("file", "line", "column")
9
@generate_ordering("file", "line", "column")
10
class SourcePosition(TextPosition):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable TextPosition does not seem to be defined.
Loading history...
11
12
    @enforce_signature
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable enforce_signature does not seem to be defined.
Loading history...
13
    def __init__(self, file: str, line=None, column=None):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable str does not seem to be defined.
Loading history...
14
        """
15
        Creates a new result position object that represents the position of a
16
        result in the source code.
17
18
        :param file:        The filename.
19
        :param line:        The line in file or None, the first line is 1.
20
        :param column:      The column indicating the character. The first one
21
                            in a line is 1.
22
        :raises TypeError:  Raised when
23
                            - file is not a string or None.
24
                            - line or columns are no integers.
25
        """
26
        TextPosition.__init__(self, line, column)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable column does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable line does not seem to be defined.
Loading history...
27
28
        self._file = abspath(file)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable file does not seem to be defined.
Loading history...
29
30
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
31
    def file(self):
32
        return self._file
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
33
34
    def __json__(self, use_relpath=False):
35
        _dict = get_public_members(self)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
36
        if use_relpath:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable use_relpath does not seem to be defined.
Loading history...
37
            _dict['file'] = relpath(_dict['file'])
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable _dict does not seem to be defined.
Loading history...
38
        return _dict
39