Skip to content

Commit 91703ca

Browse files
committed
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/[email protected]
1 parent cb5d942 commit 91703ca

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/tools/pgperlcritic/perlcriticrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
######################################################################
2+
#
3+
# src/tools/pgperlcritic/perlcriticrc
4+
#
5+
# config file for perlcritic for Postgres project
6+
#
7+
#####################################################################
8+
9+
severity = 5
10+
11+
theme = core
12+
13+
# allow octal constants with leading zeros
14+
[-ValuesAndExpressions::ProhibitLeadingZeros]

src/tools/pgperlcritic/pgperlcritic

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
# src/tools/pgperlcritic/pgperlcritic
4+
5+
test -f src/tools/pgperlcritic/perlcriticrc || {
6+
echo could not find src/tools/pgperlcritic/perlcriticrc
7+
exit 1
8+
}
9+
10+
set -e
11+
12+
# set this to override default perlcritic program:
13+
PERLCRITIC=${PERLCRITIC:-perlcritic}
14+
15+
# locate all Perl files in the tree
16+
{
17+
# take all .pl and .pm files
18+
find . -type f -a \( -name '*.pl' -o -name '*.pm' \) -print
19+
# take executable files that file(1) thinks are perl files
20+
find . -type f -perm -100 -exec file {} \; -print |
21+
egrep -i ':.*perl[0-9]*\>' |
22+
cut -d: -f1
23+
} |
24+
sort -u |
25+
xargs $PERLCRITIC \
26+
--quiet \
27+
--program-extensions .pl \
28+
--profile=src/tools/pgperlcritic/perlcriticrc

0 commit comments

Comments
 (0)