Pull request 2269: ADG-8932 Upd all
Squashed commit of the following: commit 00fc45877776ed7d1c59be26330f6f16d784ead2 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Aug 20 16:21:25 2024 +0300 all: imp lint commit b04d9cd334a92faf21787e7e1ebf20d5e5fd0bee Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Aug 20 14:40:18 2024 +0300 all: upd all commit f151f8c3139a0d8ac8cc5cf4926710b8d3f98846 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Aug 16 13:12:36 2024 +0300 all: upd proxy
This commit is contained in:
@@ -6,7 +6,7 @@ set -e -f -u
|
||||
# Bump this number every time a significant change is made to this
|
||||
# script.
|
||||
#
|
||||
# AdGuard-Project-Version: 2
|
||||
# AdGuard-Project-Version: 3
|
||||
|
||||
# TODO(a.garipov): Add pre-merge-commit.
|
||||
|
||||
@@ -56,13 +56,15 @@ prompt() {
|
||||
# Warn the programmer about unstaged changes and untracked files, but do
|
||||
# not fail the commit, because those changes might be temporary or for
|
||||
# a different branch.
|
||||
#
|
||||
# shellcheck disable=SC2016
|
||||
awk_prog='substr($2, 2, 1) != "." { print $9; } $1 == "?" { print $2; }'
|
||||
readonly awk_prog
|
||||
|
||||
unstaged="$( git status --porcelain=2 | awk "$awk_prog" )"
|
||||
readonly unstaged
|
||||
|
||||
if [ "$unstaged" != "" ]
|
||||
if [ "$unstaged" != '' ]
|
||||
then
|
||||
printf 'WARNING: you have unstaged changes:\n\n%s\n\n' "$unstaged"
|
||||
prompt
|
||||
@@ -73,7 +75,7 @@ fi
|
||||
temp_todos="$( git grep -e 'TODO.*!!' -- ':!scripts/hooks/pre-commit' || : )"
|
||||
readonly temp_todos
|
||||
|
||||
if [ "$temp_todos" != "" ]
|
||||
if [ "$temp_todos" != '' ]
|
||||
then
|
||||
printf 'WARNING: you have temporary todos:\n\n%s\n\n' "$temp_todos"
|
||||
prompt
|
||||
@@ -82,22 +84,32 @@ fi
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
|
||||
if [ "$( git diff --cached --name-only -- 'client/*.js' )" ]
|
||||
if [ "$( git diff --cached --name-only -- 'client/*.js' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" js-lint js-test
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.go' '*.mod' '*.sh' 'Makefile' )" ]
|
||||
if [ "$( git diff --cached --name-only -- '*.go' '*.mod' 'Makefile' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" go-os-check go-lint go-test
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
|
||||
if [ "$( git diff --cached --name-only -- '*.md' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" md-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.sh' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" sh-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" txt-lint
|
||||
fi
|
||||
|
||||
if [ "$( git diff --cached --name-only -- './openapi/openapi.yaml' )" ]
|
||||
if [ "$( git diff --cached --name-only -- './openapi/openapi.yaml' || true )" != '' ]
|
||||
then
|
||||
make VERBOSE="$verbose" openapi-lint
|
||||
fi
|
||||
|
||||
@@ -91,6 +91,7 @@ elif [ "${GOMIPS:-}" != '' ]
|
||||
then
|
||||
ldflags="${ldflags} -X ${version_pkg}.gomips=${GOMIPS}"
|
||||
fi
|
||||
readonly ldflags
|
||||
|
||||
# Allow users to limit the build's parallelism.
|
||||
parallelism="${PARALLELISM:-}"
|
||||
@@ -143,7 +144,7 @@ then
|
||||
fi
|
||||
|
||||
"$go" build\
|
||||
--ldflags "$ldflags"\
|
||||
--ldflags="$ldflags"\
|
||||
"$race_flags"\
|
||||
"$tags_flags"\
|
||||
--trimpath\
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a significant change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 5
|
||||
# AdGuard-Project-Version: 8
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
@@ -35,9 +35,12 @@ set -f -u
|
||||
# blocklist_imports is a simple check against unwanted packages. The following
|
||||
# packages are banned:
|
||||
#
|
||||
# * Packages errors and log are replaced by our own packages in the
|
||||
# * Package errors is replaced by our own package in the
|
||||
# github.com/AdguardTeam/golibs module.
|
||||
#
|
||||
# * Packages golang.org/x/exp/slices and golang.org/x/net/context have been
|
||||
# moved into stdlib.
|
||||
#
|
||||
# * Package io/ioutil is soft-deprecated.
|
||||
#
|
||||
# * Package reflect is often an overkill, and for deep comparisons there are
|
||||
@@ -51,10 +54,6 @@ set -f -u
|
||||
#
|
||||
# * Package unsafe is… unsafe.
|
||||
#
|
||||
# * Package golang.org/x/exp/slices has been moved into stdlib.
|
||||
#
|
||||
# * Package golang.org/x/net/context has been moved into stdlib.
|
||||
#
|
||||
# Currently, the only standard exception are files generated from protobuf
|
||||
# schemas, which use package reflect. If your project needs more exceptions,
|
||||
# add and document them.
|
||||
@@ -62,17 +61,17 @@ set -f -u
|
||||
# TODO(a.garipov): Add golibs/log.
|
||||
#
|
||||
# TODO(a.garipov): Add deprecated package golang.org/x/exp/maps once all
|
||||
# projects switch to Go 1.22.
|
||||
# projects switch to Go 1.23.
|
||||
blocklist_imports() {
|
||||
git grep\
|
||||
-e '[[:space:]]"errors"$'\
|
||||
-e '[[:space:]]"golang.org/x/exp/slices"$'\
|
||||
-e '[[:space:]]"golang.org/x/net/context"$'\
|
||||
-e '[[:space:]]"io/ioutil"$'\
|
||||
-e '[[:space:]]"log"$'\
|
||||
-e '[[:space:]]"reflect"$'\
|
||||
-e '[[:space:]]"sort"$'\
|
||||
-e '[[:space:]]"unsafe"$'\
|
||||
-e '[[:space:]]"golang.org/x/exp/slices"$'\
|
||||
-e '[[:space:]]"golang.org/x/net/context"$'\
|
||||
-n\
|
||||
-- '*.go'\
|
||||
':!*.pb.go'\
|
||||
@@ -105,6 +104,7 @@ underscores() {
|
||||
-e '_bsd.go'\
|
||||
-e '_darwin.go'\
|
||||
-e '_freebsd.go'\
|
||||
-e '_generate.go'\
|
||||
-e '_linux.go'\
|
||||
-e '_next.go'\
|
||||
-e '_openbsd.go'\
|
||||
@@ -140,7 +140,7 @@ run_linter -e gofumpt --extra -e -l .
|
||||
|
||||
# TODO(a.garipov): golint is deprecated, find a suitable replacement.
|
||||
|
||||
run_linter "$GO" vet ./...
|
||||
run_linter "${GO:-go}" vet ./...
|
||||
|
||||
run_linter govulncheck ./...
|
||||
|
||||
@@ -212,8 +212,6 @@ git ls-files -- 'Makefile' '*.conf' '*.go' '*.mod' '*.sh' '*.yaml' '*.yml'\
|
||||
| xargs misspell --error\
|
||||
| sed -e 's/^/misspell: /'
|
||||
|
||||
run_linter looppointer ./...
|
||||
|
||||
run_linter nilness ./...
|
||||
|
||||
# TODO(a.garipov): Enable for all.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a significant change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 3
|
||||
# AdGuard-Project-Version: 4
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
@@ -42,7 +42,6 @@ rm -f\
|
||||
bin/gosec\
|
||||
bin/govulncheck\
|
||||
bin/ineffassign\
|
||||
bin/looppointer\
|
||||
bin/misspell\
|
||||
bin/nilness\
|
||||
bin/shadow\
|
||||
@@ -66,7 +65,6 @@ env\
|
||||
github.com/golangci/misspell/cmd/misspell\
|
||||
github.com/gordonklaus/ineffassign\
|
||||
github.com/kisielk/errcheck\
|
||||
github.com/kyoh86/looppointer/cmd/looppointer\
|
||||
github.com/securego/gosec/v2/cmd/gosec\
|
||||
github.com/uudashr/gocognit/cmd/gocognit\
|
||||
golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment\
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a significant change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 1
|
||||
# AdGuard-Project-Version: 2
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
@@ -29,5 +29,6 @@ go="${GO:-go}"
|
||||
readonly go
|
||||
|
||||
cd ./internal/tools/
|
||||
"$go" get -u
|
||||
|
||||
"$go" get -u "$x_flags"
|
||||
"$go" mod tidy
|
||||
|
||||
23
scripts/make/md-lint.sh
Normal file
23
scripts/make/md-lint.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a remarkable change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 2
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
|
||||
set -e -f -u
|
||||
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# NOTE: Adjust for your project.
|
||||
# markdownlint\
|
||||
# ./README.md\
|
||||
# ;
|
||||
|
||||
# TODO(e.burkov): Lint markdown documents within this project.
|
||||
39
scripts/make/sh-lint.sh
Normal file
39
scripts/make/sh-lint.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This comment is used to simplify checking local copies of the script. Bump
|
||||
# this number every time a remarkable change is made to this script.
|
||||
#
|
||||
# AdGuard-Project-Version: 2
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
|
||||
# Don't use -f, because we use globs in this script.
|
||||
set -e -u
|
||||
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# NOTE: Adjust for your project.
|
||||
#
|
||||
# TODO(e.burkov): Add build-docker.sh, build-release.sh and install.sh.
|
||||
shellcheck -e 'SC2250' -f 'gcc' -o 'all' -x --\
|
||||
./scripts/hooks/*\
|
||||
./scripts/snap/*\
|
||||
./scripts/make/clean.sh\
|
||||
./scripts/make/go-bench.sh\
|
||||
./scripts/make/go-build.sh\
|
||||
./scripts/make/go-deps.sh\
|
||||
./scripts/make/go-fuzz.sh\
|
||||
./scripts/make/go-lint.sh\
|
||||
./scripts/make/go-test.sh\
|
||||
./scripts/make/go-tools.sh\
|
||||
./scripts/make/go-upd-tools.sh\
|
||||
./scripts/make/helper.sh\
|
||||
./scripts/make/md-lint.sh\
|
||||
./scripts/make/sh-lint.sh\
|
||||
./scripts/make/txt-lint.sh\
|
||||
./scripts/make/version.sh\
|
||||
;
|
||||
Reference in New Issue
Block a user