-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add a basic linter for postgres code using [arc lint script-and-regex][1]. Implement the script using a bash script that runs some grep searches on the given file. It is not powerful enough to check for certain things such as whether indentation is aligned properly with respect to other lines, but it is still better to have some basic enforcement over nothing. [1]: https://secure.phabricator.com/book/phabricator/article/arcanist_lint_script_and_regex/ Jira: DB-13743 Test Plan: manually check arc lint on a few postgres files Close: #24671 Reviewers: mihnea, tfoucher Reviewed By: tfoucher Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D36535
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
# Simple linter for postgres code. | ||
grep -nE '\s+$' "$1" | sed 's/^/error:trailing_whitespace:/' | ||
grep -nvE '^( * {0,3}\S|$)' "$1" | sed 's/^/error:leading_whitespace:/' | ||
grep -nE '(\)|else|else if)\s+{$' "$1" | sed 's/^/warning:likely_bad_brace:/' | ||
|
||
grep -nE ',\s*errmsg(_plural)?\(' "$1" | sed 's/^/error:missing_linebreak_before_errmsg:/' | ||
grep -nE ',\s*errdetail(_plural)?\(' "$1" | sed 's/^/error:missing_linebreak_before_errdetail:/' | ||
grep -nE ',\s*errhint\(' "$1" | sed 's/^/error:missing_linebreak_before_errhint:/' | ||
|
||
grep -nE 'errmsg(_plural)?\("[A-Z][a-z]' "$1" | sed 's/^/warning:likely_bad_capitalization_in_errmsg:/' | ||
grep -nE 'errdetail(_plural)?\("[a-z]' "$1" | sed 's/^/warning:likely_bad_lowercase_in_errdetail:/' | ||
grep -nE 'errhint\("[a-z]' "$1" | sed 's/^/warning:likely_bad_lowercase_in_errhint:/' |