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

bears.perl.PerlCriticBear   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %
Metric Value
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 2
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