Pull request: all: use http method constants

Merge in DNS/adguard-home from method-const to master

Squashed commit of the following:

commit ae6d6699a25ca04ba92aa53258d46e50233a9e00
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 29 22:03:59 2021 +0300

    all: use http method constants
This commit is contained in:
Ainar Garipov
2021-02-04 14:15:34 +03:00
parent 0c127039cf
commit 2638e271fe
9 changed files with 62 additions and 38 deletions

View File

@@ -23,6 +23,10 @@ fi
# variables.
set -f -u
# Deferred Helpers
not_found_msg='
looks like a binary not found error.
make sure you have installed the linter binaries using:
@@ -43,6 +47,10 @@ not_found() {
}
trap not_found EXIT
# Simple Analyzers
# blocklist_imports is a simple check against unwanted packages.
# Currently it only looks for package log which is replaced by our own
# package github.com/AdguardTeam/golibs/log.
@@ -50,6 +58,12 @@ blocklist_imports() {
git grep -F -e '"log"' -- '*.go' || exit 0;
}
# method_const is a simple check against the usage of some raw strings
# and numbers where one should use named constants.
method_const() {
git grep -F -e '"GET"' -e '"POST"' -- '*.go' || exit 0;
}
# underscores is a simple check against Go filenames with underscores.
underscores() {
git ls-files '*_*.go' | { grep -F -e '_darwin.go' \
@@ -58,6 +72,10 @@ underscores() {
-v || exit 0; }
}
# Helpers
# exit_on_output exits with a nonzero exit code if there is anything in
# the command's combined output.
exit_on_output() (
@@ -98,8 +116,14 @@ exit_on_output() (
return "$exitcode"
)
# Checks
exit_on_output blocklist_imports
exit_on_output method_const
exit_on_output underscores
exit_on_output gofumpt --extra -l -s .