Completed
Pull Request — master (#1297)
by Sudheesh
01:36
created

bears.perl.PerlCriticBear.run()   A

Complexity

Conditions 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 16
rs 9.4285
1
import re
2
3
from coalib.bearlib.abstractions.Lint import Lint
4
from coalib.bears.LocalBear import LocalBear
5
from coalib.misc.Shell import escape_path_argument
6
7
8
class PerlCriticBear(LocalBear, Lint):
9
    executable = 'perlcritic'
10
    arguments = '--no-color --verbose "%l|%c|%s|%p|%m (%e)"'
11
    output_regex = re.compile(
12
            r'(?P<line>\d+)\|(?P<column>\d+)\|(?P<severity>\d+)\|'
13
            r'(?P<origin>.*?)\|(?P<message>.*)')
14
15
    def run(self,
16
            filename,
17
            file,
18
            perlcritic_config: str=""):
19
        '''
20
        Checks the code with perlcritic. This will run perlcritic over
21
        each of the files seperately
22
23
        :param perlcritic_config: Location of the perlcriticrc config file.
24
        '''
25
26
        if perlcritic_config:
27
            self.arguments += (" --config "
28
                               + escape_path_argument(perlcritic_config))
29
30
        return self.lint(filename)
31