Completed
Pull Request — master (#1146)
by Lasse
01:52
created

bears.c_languages.CPPLintBear.run()   A

Complexity

Conditions 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
dl 0
loc 15
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.settings.Setting import typed_list
6
7
8
class CPPLintBear(LocalBear, Lint):
9
    executable = 'cpplint'
10
    output_regex = re.compile(
11
        r'(?P<filename>.+\..+):(?P<line>\d+):\s(?P<message>.+)')
12
    use_stderr = True
13
14
    def run(self,
15
            filename,
16
            file,
17
            cpplint_ignore: typed_list(str)=[],
18
            cpplint_include: typed_list(str)=[]):
19
        '''
20
        Checks the code with `cpplint` on each file separately.
21
22
        :param cpplint_ignore:
23
        :param cpplint_include:
24
        '''
25
        ignore = ','.join('-'+part.strip() for part in cpplint_ignore)
26
        include = ','.join('+'+part.strip() for part in cpplint_include)
27
        self.arguments = '--filter='+ignore+','+include
28
        return self.lint(filename)
29