Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49e3034

Browse files
JelteFCommitfest Bot
authored andcommitted
Combine all formatting and linting tools into pgcheck
Over time our pgindent script has gotten a lot of quality of life features, like the --commit, --diff, --check, and --jobs flags. Our pgperltidy, pgperlcritic and pgperlsyncheck scripts were missing all these features. This commit introduces a new tool called "pgcheck" that combines the functionality of all these tools, so all of them can benefit from the improvements that have been made to pgindent. The old scripts are still available as simple wrappers around pgcheck.
1 parent 619c378 commit 49e3034

8 files changed

Lines changed: 397 additions & 82 deletions

File tree

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ indent_style = space
6767
tab_width = unset
6868
indent_size = 1
6969

70+
[src/tools/pgcheck/pgcheck]
71+
trim_trailing_whitespace = true
72+
insert_final_newline = true
73+
indent_style = tab
74+
tab_width = 4
75+
7076
[*.data]
7177
indent_style = unset
7278
indent_size = unset

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
README conflict-marker-size=48
1616
README.* conflict-marker-size=48
1717

18+
# Some files are perl even without perly extensions
19+
src/tools/pgcheck/pgcheck whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4
20+
1821
# Certain data files that contain special whitespace, and other special cases
1922
*.data -whitespace
2023
contrib/pgcrypto/sql/pgp-armor.sql whitespace=-blank-at-eol

src/tools/perlcheck/pgperlcritic

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
#!/bin/sh
22

3-
# src/tools/perlcheck/pgperlcritic
3+
# Copyright (c) 2021-2026, PostgreSQL Global Development Group
44

5-
test -f src/tools/perlcheck/perlcriticrc || {
6-
echo could not find src/tools/perlcheck/perlcriticrc
7-
exit 1
8-
}
5+
# Wrapper that runs pgcheck in perlcritic-only mode.
6+
# See src/tools/pgcheck/pgcheck for the full implementation.
97

10-
set -e
11-
12-
# set this to override default perlcritic program:
13-
PERLCRITIC=${PERLCRITIC:-perlcritic}
14-
15-
. src/tools/perlcheck/find_perl_files
16-
17-
find_perl_files "$@" | xargs $PERLCRITIC \
18-
--quiet \
19-
--program-extensions .pl \
20-
--profile=src/tools/perlcheck/perlcriticrc
8+
exec "$(dirname "$0")/../pgcheck/pgcheck" --perlcritic "$@"

src/tools/perlcheck/pgperlsyncheck

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
#!/bin/sh
22

3-
# script to detect compile time errors and warnings in all perl files
3+
# Copyright (c) 2021-2026, PostgreSQL Global Development Group
44

5-
INCLUDES="-I src/backend/catalog"
6-
INCLUDES="-I src/test/perl -I src/backend/utils/mb/Unicode $INCLUDES"
7-
INCLUDES="-I src/bin/pg_rewind -I src/test/ssl/t $INCLUDES"
5+
# Wrapper that runs pgcheck in perl-syncheck-only mode.
6+
# See src/tools/pgcheck/pgcheck for the full implementation.
87

9-
set -e
10-
11-
. src/tools/perlcheck/find_perl_files
12-
13-
# for zsh
14-
setopt shwordsplit 2>/dev/null || true
15-
16-
find_perl_files "$@" | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
8+
exec "$(dirname "$0")/../pgcheck/pgcheck" --perl-syncheck "$@"

src/tools/pgcheck/README

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
pgcheck
2+
=======
3+
4+
pgcheck is a unified tool for formatting and checking PostgreSQL's C
5+
and Perl code. It consolidates the functionality of pgindent,
6+
pgperltidy, pgperlcritic, and pgperlsyncheck into a single script.
7+
The individual tool scripts still exist as thin wrappers around pgcheck.
8+
9+
src/tools/pgcheck/pgcheck
10+
11+
By default pgcheck runs all tools on the current directory. You can select
12+
specific ones or use a variety of options:
13+
14+
src/tools/pgcheck/pgcheck --pgindent src contrib
15+
src/tools/pgcheck/pgcheck --perltidy --commit HEAD --check --diff
16+
src/tools/pgcheck/pgcheck --perlcritic --perl-syncheck
17+
18+
Run pgcheck --help for the full list of options.
19+
20+
See src/tools/pgindent/README for prerequisites and detailed usage
21+
instructions.

0 commit comments

Comments
 (0)