Completed
Pull Request — master (#1080)
by Lasse
01:41
created

bears.NaturalLanguage.AlexBear   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %
Metric Value
dl 0
loc 20
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 3
1
import re
2
3
from bears.linters.CorrectionBasedBear import CorrectionBasedBear
4
from coalib.results.Result import Result
5
6
7
class AlexBear(CorrectionBasedBear):
8
    BINARY = 'alex'
9
    REGEX = (r'^\s+(?P<line>\d+):(?P<col>\d+)\-(?P<toline>\d+):(?P<tocol>\d+)'
10
             r'\s+(?:(?P<warning>warning)) (?P<message>.+)')
11
12
    def run(self, filename, file):
13
        output, errors = self._run_process(file, '')
14
        self._print_errors(errors)
15
16
        for line in output:
17
            match = re.match(self.REGEX, line)
18
            if match:
19
                groupdict = match.groupdict()
20
                yield Result.from_values(self,
21
                                         groupdict['message'],
22
                                         filename,
23
                                         line=int(groupdict['line']),
24
                                         column=int(groupdict['col']),
25
                                         end_line=int(groupdict['toline']),
26
                                         end_column=int(groupdict['tocol']))
27