| Total Complexity | 2 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| 1 | import re |
||
| 8 | class PHPLintBear(LocalBear, Lint): |
||
| 9 | executable = 'php' |
||
| 10 | arguments = '-l -n -d display_errors=On -d log_errors=Off' |
||
| 11 | output_regex = re.compile( |
||
| 12 | r'(?P<severity>\S+) error: ' |
||
| 13 | r'(?P<message>.*) in (?P<file_name>.*) on line (?P<line>\d+)') |
||
| 14 | |||
| 15 | @staticmethod |
||
| 16 | def _get_groupdict(match): |
||
| 17 | groups = Lint._get_groupdict(match) |
||
| 18 | # As `php -l` only shows Fatal errorsor Parsing errors both are |
||
| 19 | # considered as Major |
||
| 20 | groups['severity'] = RESULT_SEVERITY.MAJOR |
||
| 21 | return groups |
||
| 22 | |||
| 23 | def run(self, filename, file): |
||
| 24 | ''' |
||
| 25 | Checks the code with `php -l`. This runs it on each file separately. |
||
| 26 | ''' |
||
| 27 | return self.lint(filename) |
||
| 28 |