mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-27 09:18:58 +03:00
bdff46ec1d
Merge in DNS/adguard-home from 2102-dnsrewrite to master
Updates #2102.
Squashed commit of the following:
commit 8490fc18179d38c4b162ff9b257fea1f8535afbd
Merge: d9448ddca e7f7799b3
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Dec 21 16:44:00 2020 +0300
Merge branch 'master' into 2102-dnsrewrite
commit d9448ddca6d4ef3635d767e3e496e44c35d3fc6e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Dec 21 15:44:54 2020 +0300
querylog: support dnsrewrite rules
commit 40aa5d30acddf29fb90d249d8806941c6e1915a4
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Dec 18 19:27:40 2020 +0300
all: improve documentation
commit f776a0cd63b1640ba1e5210d9301e2a2801fd824
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Dec 18 19:09:08 2020 +0300
dnsfilter: prevent panics, improve docs
commit e14073b7500d9ed827a151c5b8fb863c980c10e8
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Dec 4 15:51:02 2020 +0300
all: add $dnsrewrite handling
115 lines
2.4 KiB
Bash
115 lines
2.4 KiB
Bash
#!/bin/sh
|
|
|
|
# Verbosity levels:
|
|
# 0 = Don't print anything except for errors.
|
|
# 1 = Print commands, but not nested commands.
|
|
# 2 = Print everything.
|
|
test "${VERBOSE:=0}" -gt '0' && set -x
|
|
|
|
# Set $EXITONERROR to zero to see all errors.
|
|
test "${EXITONERROR:=1}" = '0' && set +e || set -e
|
|
|
|
# We don't need glob expansions and we want to see errors about unset
|
|
# variables.
|
|
set -f -u
|
|
|
|
not_found_msg='
|
|
looks like a binary not found error.
|
|
make sure you have installed the linter binaries using:
|
|
|
|
$ make go-install-tools
|
|
'
|
|
|
|
not_found() {
|
|
if [ "$?" = '127' ]
|
|
then
|
|
# Code 127 is the exit status a shell uses when
|
|
# a command or a file is not found, according to the
|
|
# Bash Hackers wiki.
|
|
#
|
|
# See https://wiki.bash-hackers.org/dict/terms/exit_status.
|
|
echo "$not_found_msg" 1>&2
|
|
fi
|
|
}
|
|
trap not_found EXIT
|
|
|
|
# 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.
|
|
blocklist_imports() {
|
|
git grep -F -e '"log"' -- '*.go' || exit 0;
|
|
}
|
|
|
|
# underscores is a simple check against Go filenames with underscores.
|
|
underscores() {
|
|
git ls-files '*_*.go' | { grep -F -e '_darwin.go' \
|
|
-e '_freebsd.go' -e '_linux.go' -e '_others.go' \
|
|
-e '_test.go' -e '_unix.go' -e '_windows.go' \
|
|
-v || exit 0; }
|
|
}
|
|
|
|
# exit_on_output exits with a nonzero exit code if there is anything in
|
|
# the command's combined output.
|
|
exit_on_output() {
|
|
test "$VERBOSE" -lt '2' && set +x
|
|
|
|
cmd="$1"
|
|
shift
|
|
|
|
exitcode='0'
|
|
output="$("$cmd" "$@" 2>&1)"
|
|
if [ "$output" != '' ]
|
|
then
|
|
if [ "$*" != '' ]
|
|
then
|
|
echo "combined output of '$cmd $@':"
|
|
else
|
|
echo "combined output of '$cmd':"
|
|
fi
|
|
|
|
echo "$output"
|
|
|
|
exitcode='1'
|
|
fi
|
|
|
|
test "$VERBOSE" -gt '0' && set -x
|
|
|
|
return "$exitcode"
|
|
}
|
|
|
|
exit_on_output blocklist_imports
|
|
|
|
exit_on_output underscores
|
|
|
|
exit_on_output gofumpt --extra -l -s .
|
|
|
|
golint --set_exit_status ./...
|
|
|
|
"$GO" vet ./...
|
|
|
|
gocyclo --over 20 .
|
|
|
|
gosec --quiet .
|
|
|
|
ineffassign .
|
|
|
|
unparam ./...
|
|
|
|
git ls-files -- '*.go' '*.md' '*.yaml' '*.yml' | xargs misspell --error
|
|
|
|
looppointer ./...
|
|
|
|
nilness ./...
|
|
|
|
# TODO(a.garipov): Enable shadow after fixing all of the shadowing.
|
|
# shadow --strict ./...
|
|
|
|
# TODO(a.garipov): Enable errcheck fully after handling all errors,
|
|
# including the deferred ones, properly. Also, perhaps, enable --blank.
|
|
# errcheck ./...
|
|
exit_on_output sh -c '
|
|
errcheck --asserts ./... |\
|
|
{ grep -e "defer" -e "_test\.go:" -v || exit 0; }
|
|
'
|
|
|
|
staticcheck ./...
|