summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan2018-05-09 11:55:23 +0000
committerAndrew Dunstan2018-05-09 11:55:23 +0000
commit91703ca2144e58d041c132fb7ff06a6d1721e904 (patch)
tree244e0b28596b99b4ccc693a57a6979a54f3f7a6b
parentcb5d94295986298af666534970f9bb3715574646 (diff)
Add a script and a config file to run perlcritic
This is similar to what we do to run perltidy. For now we only run at severity level 5. Over time we can improve our perl code and reduce the severity level. Discussion: https://postgr.es/m/86aa2a3a-0c68-21fb-9560-84ad6914d561@2ndQuadrant.com
-rw-r--r--src/tools/pgperlcritic/perlcriticrc14
-rwxr-xr-xsrc/tools/pgperlcritic/pgperlcritic28
2 files changed, 42 insertions, 0 deletions
diff --git a/src/tools/pgperlcritic/perlcriticrc b/src/tools/pgperlcritic/perlcriticrc
new file mode 100644
index 00000000000..1059002ad50
--- /dev/null
+++ b/src/tools/pgperlcritic/perlcriticrc
@@ -0,0 +1,14 @@
+######################################################################
+#
+# src/tools/pgperlcritic/perlcriticrc
+#
+# config file for perlcritic for Postgres project
+#
+#####################################################################
+
+severity = 5
+
+theme = core
+
+# allow octal constants with leading zeros
+[-ValuesAndExpressions::ProhibitLeadingZeros]
diff --git a/src/tools/pgperlcritic/pgperlcritic b/src/tools/pgperlcritic/pgperlcritic
new file mode 100755
index 00000000000..40d006bef6e
--- /dev/null
+++ b/src/tools/pgperlcritic/pgperlcritic
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# src/tools/pgperlcritic/pgperlcritic
+
+test -f src/tools/pgperlcritic/perlcriticrc || {
+ echo could not find src/tools/pgperlcritic/perlcriticrc
+ exit 1
+ }
+
+set -e
+
+# set this to override default perlcritic program:
+PERLCRITIC=${PERLCRITIC:-perlcritic}
+
+# locate all Perl files in the tree
+{
+ # take all .pl and .pm files
+ find . -type f -a \( -name '*.pl' -o -name '*.pm' \) -print
+ # take executable files that file(1) thinks are perl files
+ find . -type f -perm -100 -exec file {} \; -print |
+ egrep -i ':.*perl[0-9]*\>' |
+ cut -d: -f1
+} |
+sort -u |
+xargs $PERLCRITIC \
+ --quiet \
+ --program-extensions .pl \
+ --profile=src/tools/pgperlcritic/perlcriticrc