mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
test: fix fmt pass and shorten suppression warnings
If gosimple or staticcheck had no output, it no other passes would be applied because they were using `continue`. Similarly, the suppression check never worked at all since it wasn't the result data into egrep. Fixes #7685
This commit is contained in:
parent
25ed908c18
commit
d31701bab5
17
test
17
test
@ -250,17 +250,16 @@ function fmt_pass {
|
|||||||
if which gosimple >/dev/null; then
|
if which gosimple >/dev/null; then
|
||||||
echo "Checking gosimple..."
|
echo "Checking gosimple..."
|
||||||
gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
||||||
if [ ! -n "${gosimpleResult}" ]; then
|
if [ -n "${gosimpleResult}" ]; then
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# TODO: resolve these after go1.8 migration
|
# TODO: resolve these after go1.8 migration
|
||||||
SIMPLE_CHECK_MASK="S(1024)"
|
SIMPLE_CHECK_MASK="S(1024)"
|
||||||
if egrep -v "$SIMPLE_CHECK_MASK" "${gosimpleResult}"; then
|
if echo "${gosimpleResult}" | egrep -v "$SIMPLE_CHECK_MASK"; then
|
||||||
echo -e "gosimple checking ${path} failed:\n${gosimpleResult}"
|
echo -e "gosimple checking ${path} failed:\n${gosimpleResult}"
|
||||||
exit 255
|
exit 255
|
||||||
else
|
else
|
||||||
echo -e "gosimple warning:\n${gosimpleResult}"
|
echo -e "gosimple warning:\n${gosimpleResult}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Skipping gosimple..."
|
echo "Skipping gosimple..."
|
||||||
fi
|
fi
|
||||||
@ -279,17 +278,17 @@ function fmt_pass {
|
|||||||
if which staticcheck >/dev/null; then
|
if which staticcheck >/dev/null; then
|
||||||
echo "Checking staticcheck..."
|
echo "Checking staticcheck..."
|
||||||
staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
||||||
if [ ! -n "${staticcheckResult}" ]; then
|
if [ -n "${staticcheckResult}" ]; then
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# TODO: resolve these after go1.8 migration
|
# TODO: resolve these after go1.8 migration
|
||||||
# See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
|
# See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
|
||||||
STATIC_CHECK_MASK="SA(1016|1019|2002)"
|
STATIC_CHECK_MASK="SA(1016|1019|2002)"
|
||||||
if egrep -v "$STATIC_CHECK_MASK" "${staticcheckResult}"; then
|
if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then
|
||||||
echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}"
|
echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}"
|
||||||
exit 255
|
exit 255
|
||||||
else
|
else
|
||||||
echo -e "staticcheck warning:\n${staticcheckResult}"
|
suppressed=`echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c`
|
||||||
|
echo -e "staticcheck suppressed warnings:\n${suppressed}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Skipping staticcheck..."
|
echo "Skipping staticcheck..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user