Completed
Pull Request — master (#1109)
by Abdeali
01:53
created

bears.linters.RubyLintBear   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %
Metric Value
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 5 1
1
import re
2
3
from coalib.bearlib.abstractions.Lint import Lint
4
from coalib.bears.LocalBear import LocalBear
5
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
6
7
8
class RubyLintBear(LocalBear, Lint):
9
    executable = 'ruby'
10
    arguments = '-wc'
11
    output_regex = re.compile(
12
        r'(?P<file_name>.+?):(?P<line>\d+): (?P<message>'
13
        r'.*?(?P<severity>error|warning)[,:] [^\r\n]+)\r?\n'
14
        r'(?:^[^\r\n]+\r?\n^(?P<col>.*?)\^)?')
15
    use_stderr = True
16
    severity_map = {
17
        "warning": RESULT_SEVERITY.NORMAL,
18
        "error": RESULT_SEVERITY.MAJOR}
19
20
    def run(self, filename, file):
21
        '''
22
        Checks the code with `ruby -wc` on each file separately.
23
        '''
24
        return self.lint(filename)
25