aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/check-docs16
-rwxr-xr-xcontrib/check-patches5
-rw-r--r--contrib/linters.go28
-rwxr-xr-xcontrib/sendemail-validate8
4 files changed, 35 insertions, 22 deletions
diff --git a/contrib/check-docs b/contrib/check-docs
index b92ca3c0..dd783a82 100755
--- a/contrib/check-docs
+++ b/contrib/check-docs
@@ -6,14 +6,22 @@ trap "rm -f $tmp" EXIT
global_fail=0
cmd_scd_sed='s/^\*:([a-z][a-z-]*)\*.*/\1/p'
-cmd_go_sed='/^func ([[:alnum:]]\+) Aliases() \[\]string {$/{n; s/", "/ /g; s/.*return \[\]string{"\(.*\)"}/\1/p}'
+cmd_go_sed='/^func ([[:alnum:]][[:alnum:]]*) Aliases() \[\]string {$/{n;
+ s/", "/ /g;
+ s/.*return \[\]string{"\(.*\)"}/\1/p
+}'
+
+grep_color=
+if echo . | grep --color . >/dev/null 2>&1; then
+ grep_color=--color
+fi
fail=0
sed -nre "$cmd_scd_sed" doc/*.scd > "$tmp"
for f in $(find commands -type f -name '*.go'); do
for cmd in $(sed -ne "$cmd_go_sed" "$f"); do
if ! grep -qFx "$cmd" "$tmp"; then
- grep -HnF --color "\"$cmd\"" "$f"
+ grep -HnF $grep_color "\"$cmd\"" "$f"
fail=$((fail+1))
fi
done
@@ -29,7 +37,7 @@ sed -ne "$cmd_go_sed" $(find commands -type f -name '*.go') | tr ' ' '\n' > "$tm
for f in doc/*.scd; do
for cmd in $(sed -nre "$cmd_scd_sed" "$f"); do
if ! grep -qFx "$cmd" "$tmp"; then
- grep -Hn --color "^\\*:$cmd\\*" "$f"
+ grep -Hn $grep_color "^\\*:$cmd\\*" "$f"
fail=$((fail+1))
fi
done
@@ -45,7 +53,7 @@ sed -nre 's/^\*([a-z][a-z-]*)\* = .*/\1/p' doc/*.scd > "$tmp"
for f in $(find config -type f -name '*.go'); do
for opt in $(sed -nre 's/.*`ini:"([a-z][a-z-]*)".*/\1/p' $f); do
if ! grep -qFx "$opt" "$tmp"; then
- grep -HnF --color "\"$opt\"" "$f"
+ grep -HnF $grep_color "\"$opt\"" "$f"
fail=$((fail+1))
fi
done
diff --git a/contrib/check-patches b/contrib/check-patches
index e0d82896..0fb2aa89 100755
--- a/contrib/check-patches
+++ b/contrib/check-patches
@@ -5,13 +5,14 @@ set -e
revision_range="${1?revision range}"
valid=0
-total=$(git rev-list --reverse "$revision_range" | wc -l)
+revisions=$(git rev-list --reverse "$revision_range")
+total=$(echo $revisions | wc -w)
if [ "$total" -eq 0 ]; then
exit 0
fi
n=0
-for rev in $(git rev-list --reverse "$revision_range"); do
+for rev in $revisions; do
n=$((n + 1))
title=$(git log --format='%s' -1 "$rev")
fail=false
diff --git a/contrib/linters.go b/contrib/linters.go
index 41655a67..71895e7c 100644
--- a/contrib/linters.go
+++ b/contrib/linters.go
@@ -5,8 +5,10 @@ import (
"go/token"
"go/types"
"reflect"
+ "strings"
"golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/multichecker"
)
type indirectCalls struct {
@@ -71,7 +73,10 @@ func runPanic(pass *analysis.Pass) (interface{}, error) {
}
if !isPanicHandlerInstall(block.List[0]) {
- pass.Report(panicDiag(block.Pos()))
+ path := pass.Fset.File(block.Pos()).Name()
+ if !strings.HasSuffix(path, "_test.go") {
+ pass.Report(panicDiag(block.Pos()))
+ }
}
return true
@@ -85,6 +90,9 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
calls := pass.ResultOf[PanicAnalyzer].(*indirectCalls)
for _, file := range pass.Files {
+ if strings.HasSuffix(file.Name.Name, "_test") {
+ continue
+ }
for _, decl := range file.Decls {
if f, ok := decl.(*ast.FuncDecl); ok {
if _, ok := calls.methods[f.Name.Pos()]; ok {
@@ -95,7 +103,10 @@ func runPanicIndirect(pass *analysis.Pass) (interface{}, error) {
continue
}
if !isPanicHandlerInstall(f.Body.List[0]) {
- pass.Report(panicDiag(f.Body.Pos()))
+ path := pass.Fset.File(f.Body.Pos()).Name()
+ if !strings.HasSuffix(path, "_test.go") {
+ pass.Report(panicDiag(f.Body.Pos()))
+ }
}
}
}
@@ -144,16 +155,9 @@ func isPanicHandlerInstall(stmt ast.Stmt) bool {
return i.Name == "log" && s.Sel.Name == "PanicHandler"
}
-// golang-lint required plugin api
-type analyzerPlugin struct{}
-
-// This must be implemented
-func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
- return []*analysis.Analyzer{
+func main() {
+ multichecker.Main(
PanicAnalyzer,
PanicIndirectAnalyzer,
- }
+ )
}
-
-// This must be defined and named 'AnalyzerPlugin'
-var AnalyzerPlugin analyzerPlugin
diff --git a/contrib/sendemail-validate b/contrib/sendemail-validate
index 7df38e05..dcab4aaa 100755
--- a/contrib/sendemail-validate
+++ b/contrib/sendemail-validate
@@ -30,10 +30,10 @@ validate_patch () {
git am -3 "$file"
}
-export CFLAGS="-O2 -g -Wall -Wextra -Wconversion -Warith-conversion -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer"
+export CFLAGS="-O0 -g -std=c99 -Wall -Wextra -Wconversion -Werror -Wformat-security -Wstack-protector -Wpedantic -Wmissing-prototypes"
validate_series () {
- make all tests lint check-patches
+ gmake all tests lint check-patches
}
# main -------------------------------------------------------------------------
@@ -41,8 +41,8 @@ validate_series () {
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
then
remote=$(git config --default origin --get sendemail.validateRemote) &&
- ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
- worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
+ ref=$(git config --default master --get sendemail.validateRemoteRef) &&
+ worktree=$(mktemp -t -d sendemail-validate.XXXXXXX) &&
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
git config --replace-all sendemail.validateWorktree "$worktree"
else