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

bears.css.CSSLintBear   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %
Metric Value
dl 0
loc 16
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 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