Total Complexity | 4 |
Total Lines | 32 |
Duplicated Lines | 0 % |
1 | import re |
||
9 | class JSHintBear(LocalBear, Lint): |
||
10 | executable = 'jshint' |
||
11 | arguments = '--verbose' |
||
12 | output_regex = re.compile( |
||
13 | r'.+?: line (?P<line>\d+), col (?P<col>\d+), ' |
||
14 | r'(?P<message>.+) \((?P<severity>\S\d+)\)') |
||
15 | |||
16 | def _get_groupdict(self, match): |
||
17 | groups = Lint._get_groupdict(self, match) |
||
18 | |||
19 | if groups["severity"][0] in "E": |
||
20 | groups["severity"] = RESULT_SEVERITY.MAJOR |
||
21 | else: |
||
22 | groups["severity"] = RESULT_SEVERITY.NORMAL |
||
23 | |||
24 | return groups |
||
25 | |||
26 | def run(self, |
||
27 | filename, |
||
28 | file, |
||
29 | jshint_config: str=""): |
||
30 | ''' |
||
31 | Checks the code with jshint. This will run jshint over each file |
||
32 | separately. |
||
33 | |||
34 | :param jshint_config: The location of the jshintrc config file. |
||
35 | ''' |
||
36 | if jshint_config: |
||
37 | self.arguments += (" --config " |
||
38 | + escape_path_argument(jshint_config)) |
||
39 | |||
40 | return self.lint(filename) |
||
41 |