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

bears.css.CSSLintBear.run()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 5
rs 9.4286
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 CSSLintBear(LocalBear, Lint):
9
    executable = 'csslint'
10
    arguments = '--format=compact'
11
    output_regex = re.compile(
12
        r'(?P<file_name>.+):\s*'
13
        r'(?:line (?P<line>\d+), col (?P<col>\d+), )?'
14
        r'(?P<severity>Error|Warning) - (?P<message>.*)')
15
    severity_map = {
16
        "Error": RESULT_SEVERITY.MAJOR,
17
        "Warning": RESULT_SEVERITY.NORMAL}
18
19
    def run(self, filename, file):
20
        '''
21
        Checks the code with `csslint`.
22
        '''
23
        return self.lint(filename)
24