| Total Complexity | 4 |
| Total Lines | 33 |
| 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 | @staticmethod |
||
| 17 | def _get_groupdict(match): |
||
| 18 | groups = Lint._get_groupdict(match) |
||
| 19 | |||
| 20 | if groups["severity"][0] in "E": |
||
| 21 | groups["severity"] = RESULT_SEVERITY.MAJOR |
||
| 22 | else: |
||
| 23 | groups["severity"] = RESULT_SEVERITY.NORMAL |
||
| 24 | |||
| 25 | return groups |
||
| 26 | |||
| 27 | def run(self, |
||
| 28 | filename, |
||
| 29 | file, |
||
| 30 | jshint_config: str=""): |
||
| 31 | ''' |
||
| 32 | Checks the code with jshint. This will run jshint over each file |
||
| 33 | separately. |
||
| 34 | |||
| 35 | :param jshint_config: The location of the jshintrc config file. |
||
| 36 | ''' |
||
| 37 | if jshint_config: |
||
| 38 | self.arguments += (" --config " |
||
| 39 | + escape_path_argument(jshint_config)) |
||
| 40 | |||
| 41 | return self.lint(filename) |
||
| 42 |