修复 geoip/runtime.go 真死代码:ensureServerMMDB 的 os.Stat 错误被 if-init 遮蔽,err != nil && !os.IsNotExist(err) 恒为 false(外层 err 恒 nil),防御检查从未生效;改为显式捕获 statErr,stat 非 not-exist 错误现在正确返回。基准新增第 4 维度 govet nilness+unusedwrite(文档化扩展),当前 0。

Result: {"status":"keep","total_issues":8,"golint_canonicalheader":0,"golint_errname":0,"golint_errorlint":1,"golint_exhaustive":0,"golint_forcetypeassert":0,"golint_gosec":0,"golint_intrange":0,"golint_modernize":3,"golint_nilnil":3,"golint_perfsprint":0,"golint_prealloc":0,"golint_recvcheck":1,"golint_usestdlibvars":0,"golint_wastedassign":0,"golint_total":8,"golint_test_testifylint":0,"golint_test_thelper":0,"golint_test_usetesting":0,"golint_test_total":0,"golint_vetx_total":0,"eslint_problems":0,"eslint_errors":0,"eslint_warnings":0,"tsc_errors":0,"measure_s":37}
This commit is contained in:
ryan
2026-08-16 18:25:49 +08:00
parent 85321888e0
commit d7b8f44f90
3 changed files with 32 additions and 4 deletions
+27 -1
View File
@@ -33,6 +33,32 @@ while IFS= read -r line; do
done <<< "$test_out"
echo "METRIC golint_test_total=$golang_test_total"
# ---------- Backend: govet extra analyzers (dead code / nil deref — real-bug finders) ----------
cat > /tmp/govetx.yml <<'EOF'
version: "2"
linters:
default: none
enable:
- govet
settings:
govet:
enable:
- nilness
- unusedwrite
EOF
vetx_out=$(golangci-lint run --config /tmp/govetx.yml --max-issues-per-linter=0 2>&1 || true)
rm -f /tmp/govetx.yml
golang_vetx_total=0
while IFS= read -r line; do
if [[ "$line" =~ ^\*\ ([a-zA-Z0-9_]+):\ ([0-9]+)$ ]]; then
name="${BASH_REMATCH[1]}"
n="${BASH_REMATCH[2]}"
golang_vetx_total=$((golang_vetx_total + n))
echo "METRIC golint_vetx_${name}=$n"
fi
done <<< "$vetx_out"
echo "METRIC golint_vetx_total=$golang_vetx_total"
# ---------- Frontend: eslint (repo gate) ----------
cd frontend
eslint_out=$(pnpm exec eslint . --max-warnings 0 2>&1 || true)
@@ -50,6 +76,6 @@ tsc_errors=$(grep -cE "error TS" <<< "$tsc_out" || true)
echo "METRIC tsc_errors=$tsc_errors"
end=$(date +%s)
total=$((golang_total + golang_test_total + eslint_problems + tsc_errors))
total=$((golang_total + golang_test_total + golang_vetx_total + eslint_problems + tsc_errors))
echo "METRIC total_issues=$total"
echo "METRIC measure_s=$((end - start))"