[Pkg-debile-commits] [debile-slave] 19/100: add perlcritic

Sylvestre Ledru sylvestre at alioth.debian.org
Mon Aug 19 14:53:01 UTC 2013


This is an automated email from the git hooks/post-receive script.

sylvestre pushed a commit to branch master
in repository debile-slave.

commit e9cb3b1348a1d0a6779fb11feaffa39e46b7cd42
Author: Paul Tagliamonte <tag at pault.ag>
Date:   Fri May 24 23:58:30 2013 -0400

    add perlcritic
---
 ethel/wrappers/perlcritic.py      |   27 +++++++++++++++++++++++++++
 tests/wrappers/test_perlcritic.py |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/ethel/wrappers/perlcritic.py b/ethel/wrappers/perlcritic.py
new file mode 100644
index 0000000..48e1bb9
--- /dev/null
+++ b/ethel/wrappers/perlcritic.py
@@ -0,0 +1,27 @@
+from firehose.model import Issue, Message, File, Location, Point
+import re
+
+# We require:
+# perlcritic --brutal . --verbose '%f:%l:%c %s    %p    %m\n'
+
+
+LINE_EXPR = re.compile(
+    r"(?P<file>.*):(?P<line>.*):(?P<column>.*) (?P<severity>.*)    (?P<testid>.*)    (?P<message>.*)"
+)
+
+
+def parse_perlcritic(lines):
+    for line in lines:
+        info = LINE_EXPR.match(line).groupdict()
+
+        yield Issue(cwe=None,
+                    testid=info['testid'],
+                    location=Location(
+                        file=File(info['file'], None),
+                        function=None,
+                        point=Point(int(info['line']),
+                                    int(info['column']))),
+                    severity=info['severity'],
+                    message=Message(text=info['message']),
+                    notes=None,
+                    trace=None)
diff --git a/tests/wrappers/test_perlcritic.py b/tests/wrappers/test_perlcritic.py
new file mode 100644
index 0000000..1c5be3b
--- /dev/null
+++ b/tests/wrappers/test_perlcritic.py
@@ -0,0 +1,34 @@
+from ethel.wrappers.perlcritic import parse_perlcritic
+
+
+TESTS = [
+    ('./foo.pl:1:1 4    Modules::RequireExplicitPackage    '
+        'Code not contained in explicit package',
+     'Modules::RequireExplicitPackage'),
+
+    ('./foo.pl:1:1 2    Modules::RequireVersionVar    '
+        'No package-scoped "$VERSION" variable found',
+     "Modules::RequireVersionVar"),
+
+    ('./foo.pl:3:1 1    InputOutput::RequireCheckedSyscalls    '
+        'Return value of flagged function ignored - print',
+     "InputOutput::RequireCheckedSyscalls"),
+
+    ('./foo.pl:3:1 4    Modules::RequireEndWithOne    '
+        'Module does not end with "1;"',
+     "Modules::RequireEndWithOne"),
+
+    ('./foo.pl:3:1 4    TestingAndDebugging::RequireUseWarnings    '
+        'Code before warnings are enabled',
+     "TestingAndDebugging::RequireUseWarnings"),
+
+    ('./foo.pl:3:7 1    ValuesAndExpressions::ProhibitInterpolationOfLiterals'
+        '    Useless interpolation of literal string',
+     "ValuesAndExpressions::ProhibitInterpolationOfLiterals")
+]
+
+
+def test_perlcritic():
+    for string, tid in TESTS:
+        issue = next(parse_perlcritic([string]))
+        assert issue.testid == tid

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git



More information about the Pkg-debile-commits mailing list