You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2018/12/13 16:22:45 UTC
[1/3] yetus git commit: YETUS-708. Clean up the source
Repository: yetus
Updated Branches:
refs/heads/master 492a20e05 -> 1fcaabd4e
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/scala.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/scala.sh b/precommit/src/main/shell/test-patch.d/scala.sh
index f2b599a..ba29136 100755
--- a/precommit/src/main/shell/test-patch.d/scala.sh
+++ b/precommit/src/main/shell/test-patch.d/scala.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type scalac
add_test_type scaladoc
@@ -122,8 +124,7 @@ function scalac_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} "^/.*.scala:[0-9]*:" "${input}" > "${output}"
+ "${GREP}" "^/.*.scala:[0-9]*:" "${input}" > "${output}"
}
## @description Helper for generic_logfilter
@@ -135,6 +136,5 @@ function scaladoc_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} "^/.*.scala:[0-9]*:" "${input}" > "${output}"
+ "${GREP}" "^/.*.scala:[0-9]*:" "${input}" > "${output}"
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/shellcheck.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/shellcheck.sh b/precommit/src/main/shell/test-patch.d/shellcheck.sh
index f0450f7..59ef98b 100755
--- a/precommit/src/main/shell/test-patch.d/shellcheck.sh
+++ b/precommit/src/main/shell/test-patch.d/shellcheck.sh
@@ -22,7 +22,7 @@ add_test_type shellcheck
SHELLCHECK_TIMER=0
SHELLCHECK_X=true
-SHELLCHECK=${SHELLCHECK:-$(which shellcheck 2>/dev/null)}
+SHELLCHECK=${SHELLCHECK:-$(command -v shellcheck 2>/dev/null)}
# files that are going to get shellcheck'd
SHELLCHECK_CHECKFILES=()
@@ -141,7 +141,7 @@ function shellcheck_logic
declare i
echo "Running shellcheck against all suspected shell scripts"
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
# need to run this every time in case patch
# add/removed files
@@ -154,7 +154,7 @@ function shellcheck_logic
"${SHELLCHECK}" -f gcc "${i}" >> "${PATCH_DIR}/${repostatus}-shellcheck-result.txt"
fi
done
- popd > /dev/null
+ popd > /dev/null || return 1
}
function shellcheck_preapply
@@ -224,13 +224,13 @@ function shellcheck_postapply
> "${PATCH_DIR}/diff-patch-shellcheck.txt"
# shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | ${AWK} '{print $1}')
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | ${AWK} '{print $1}')
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | ${AWK} '{print $1}')
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | "${AWK}" '{print $1}')
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/shelldocs.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/shelldocs.sh b/precommit/src/main/shell/test-patch.d/shelldocs.sh
index d52fa6b..67f94d9 100755
--- a/precommit/src/main/shell/test-patch.d/shelldocs.sh
+++ b/precommit/src/main/shell/test-patch.d/shelldocs.sh
@@ -14,13 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type shelldocs
SHELLDOCS_TIMER=0
-SHELLDOCS=${SHELLDOCS}
+SHELLDOCS=$(command -v shelldocs)
if [[ -z ${SHELLDOCS} ]]; then
- for shelldocsexec in "${BINDIR}/shelldocs" "${BINDIR}/../shelldocs/shelldocs.py"; do
+ for shelldocsexec in \
+ "${BINDIR}/shelldocs" \
+ "${BINDIR}/../shelldocs/shelldocs.py"\
+ "${BASEDIR}/shelldocs/src/main/python/shelldocs.py"; do
if [[ -f ${shelldocsexec} && -x ${shelldocsexec} ]]; then
SHELLDOCS=${shelldocsexec}
break
@@ -108,13 +113,13 @@ function shelldocs_preapply
start_clock
echo "Running shelldocs against all identifiable shell scripts"
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in $(shelldocs_private_findbash); do
if [[ -f ${i} ]]; then
- ${SHELLDOCS} --input "${i}" --lint >> "${PATCH_DIR}/branch-shelldocs-result.txt"
+ "${SHELLDOCS}" --input "${i}" --lint >> "${PATCH_DIR}/branch-shelldocs-result.txt"
fi
done
- popd > /dev/null
+ popd > /dev/null || return 1
# keep track of how much as elapsed for us already
SHELLDOCS_TIMER=$(stop_clock)
@@ -146,7 +151,7 @@ function shelldocs_postapply
# we re-check this in case one has been added
for i in $(shelldocs_private_findbash); do
if [[ -f ${i} ]]; then
- ${SHELLDOCS} --input "${i}" --lint >> "${PATCH_DIR}/patch-shelldocs-result.txt"
+ "${SHELLDOCS}" --input "${i}" --lint >> "${PATCH_DIR}/patch-shelldocs-result.txt"
fi
done
@@ -157,13 +162,13 @@ function shelldocs_postapply
> "${PATCH_DIR}/diff-patch-shelldocs.txt"
# shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-shelldocs-result.txt" | ${AWK} '{print $1}')
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-shelldocs-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-shelldocs-result.txt" | ${AWK} '{print $1}')
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-shelldocs-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shelldocs.txt" | ${AWK} '{print $1}')
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shelldocs.txt" | "${AWK}" '{print $1}')
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/tap.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/tap.sh b/precommit/src/main/shell/test-patch.d/tap.sh
index 465b7f1..08d5242 100755
--- a/precommit/src/main/shell/test-patch.d/tap.sh
+++ b/precommit/src/main/shell/test-patch.d/tap.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_format tap
TAP_FAILED_TESTS=""
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/unitveto.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/unitveto.sh b/precommit/src/main/shell/test-patch.d/unitveto.sh
index e0d348e..fd88ec5 100755
--- a/precommit/src/main/shell/test-patch.d/unitveto.sh
+++ b/precommit/src/main/shell/test-patch.d/unitveto.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type unitveto
UNITVETO_RE=${UNITVETO_RE:-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/whitespace.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/whitespace.sh b/precommit/src/main/shell/test-patch.d/whitespace.sh
index 861fe3b..b52e9d1 100755
--- a/precommit/src/main/shell/test-patch.d/whitespace.sh
+++ b/precommit/src/main/shell/test-patch.d/whitespace.sh
@@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
+
WHITESPACE_EOL_IGNORE_LIST=
WHITESPACE_TABS_IGNORE_LIST='.*Makefile.*'
@@ -83,7 +86,7 @@ function whitespace_postcompile
big_console_header "Checking for whitespace issues."
start_clock
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
eolignore=$(printf -- "-e ^%s: " "${WHITESPACE_EOL_IGNORE_LIST[@]}")
tabsignore=$(printf -- "-e ^%s: " "${WHITESPACE_TABS_IGNORE_LIST[@]}")
@@ -139,12 +142,12 @@ function whitespace_postcompile
((result=result+1))
fi
+ popd >/dev/null || return 1
+
if [[ ${result} -gt 0 ]]; then
- popd >/dev/null
return 1
fi
- popd >/dev/null
add_vote_table +1 whitespace "${BUILDMODEMSG} has no whitespace issues."
return 0
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/xml.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/xml.sh b/precommit/src/main/shell/test-patch.d/xml.sh
index 1e56905..e8cd0ed 100755
--- a/precommit/src/main/shell/test-patch.d/xml.sh
+++ b/precommit/src/main/shell/test-patch.d/xml.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
declare -a XML_FILES
add_test_type xml
@@ -56,7 +58,7 @@ function xml_postcompile
start_clock
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.xml$ && -f ${i} ]]; then
if ! "${js}" -e "XMLDocument(arguments[0])" "${i}" > "${PATCH_DIR}/xml.txt.tmp" 2>&1; then
@@ -72,7 +74,7 @@ function xml_postcompile
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ -f "${PATCH_DIR}/xml.txt.tmp" ]]; then
rm "${PATCH_DIR}/xml.txt.tmp"
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index 5f25afb..9a78057 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -70,6 +70,7 @@ function setup_defaults
set_yetus_version
+ #shellcheck disable=SC2153
if [[ ${VERSION} =~ SNAPSHOT$ ]]; then
version="in-progress"
fi
@@ -113,6 +114,7 @@ function module_file_fragment
if [[ ${mod} = \. ]]; then
echo root
else
+ #shellcheck disable=SC1003
echo "$1" | tr '/' '_' | tr '\\' '_'
fi
}
@@ -279,7 +281,7 @@ function add_vote_table
function report_jvm_version
{
#shellcheck disable=SC2016
- "${1}/bin/java" -version 2>&1 | head -1 | ${AWK} '{print $NF}' | tr -d \"
+ "${1}/bin/java" -version 2>&1 | head -1 | "${AWK}" '{print $NF}' | tr -d \"
}
## @description Verify if a given test is multijdk
@@ -410,13 +412,13 @@ function big_console_header
{
local text="$*"
local spacing=$(( (75+${#text}) /2 ))
- printf "\n\n"
+ printf '\n\n'
echo "============================================================================"
echo "============================================================================"
- printf "%*s\n" ${spacing} "${text}"
+ printf '%*s\n' ${spacing} "${text}"
echo "============================================================================"
echo "============================================================================"
- printf "\n\n"
+ printf '\n\n'
}
## @description Find the largest size of a column of an array
@@ -456,7 +458,7 @@ function write_comment
declare bug
for bug in ${BUGCOMMENTS}; do
- if declare -f ${bug}_write_comment >/dev/null; then
+ if declare -f "${bug}_write_comment" >/dev/null; then
"${bug}_write_comment" "${commentfile}"
fi
done
@@ -511,8 +513,8 @@ function compute_gitdiff
local content
local outfile="${PATCH_DIR}/computegitdiff.${RANDOM}"
- pushd "${BASEDIR}" >/dev/null
- ${GIT} add --all --intent-to-add
+ pushd "${BASEDIR}" >/dev/null || return 1
+ "${GIT}" add --all --intent-to-add
while read -r line; do
if [[ ${line} =~ ^\+\+\+ ]]; then
file="./"$(echo "${line}" | cut -f2- -d/)
@@ -545,7 +547,7 @@ function compute_gitdiff
while read -r content; do
((actual=counter+startline))
echo "${file}:${actual}:" >> "${GITDIFFLINES}"
- printf "%s:%s:%s\n" "${file}" "${actual}" "${content}" >> "${GITDIFFCONTENT}"
+ printf '%s:%s:%s\n' "${file}" "${actual}" "${content}" >> "${GITDIFFCONTENT}"
((counter=counter+1))
done < "${outfile}"
rm "${outfile}"
@@ -567,7 +569,7 @@ function compute_gitdiff
touch "${GITUNIDIFFLINES}"
fi
- popd >/dev/null
+ popd >/dev/null || return 1
}
## @description generate an index of unified diff lines vs. modified/added lines
@@ -596,11 +598,11 @@ function compute_unidiff
filen=${fn##./}
if [[ -f "${filen}" ]]; then
- ${GIT} diff "${filen}" \
+ "${GIT}" diff "${filen}" \
| tail -n +6 \
- | ${GREP} -n '^+' \
- | ${GREP} -vE '^[0-9]*:\+\+\+' \
- | ${SED} -e 's,^\([0-9]*:\)\+,\1,g' \
+ | "${GREP}" -n '^+' \
+ | "${GREP}" -vE '^[0-9]*:\+\+\+' \
+ | "${SED}" -e 's,^\([0-9]*:\)\+,\1,g' \
-e "s,^,./${filen}:,g" \
>> "${tmpfile}"
fi
@@ -613,7 +615,7 @@ function compute_unidiff
# ./filename:real number:diff number
# shellcheck disable=SC2016
paste -d: "${GITDIFFLINES}" "${tmpfile}" \
- | ${AWK} -F: '{print $1":"$2":"$5":"$6}' \
+ | "${AWK}" -F: '{print $1":"$2":"$5":"$6}' \
>> "${GITUNIDIFFLINES}"
rm "${tmpfile}"
@@ -804,7 +806,7 @@ function yetus_usage
yetus_reset_usage
for plugin in ${BUILDTOOLS} ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS}; do
- if declare -f ${plugin}_usage >/dev/null 2>&1; then
+ if declare -f "${plugin}_usage" >/dev/null 2>&1; then
echo ""
echo "'${plugin}' plugin usage options:"
"${plugin}_usage"
@@ -1027,8 +1029,7 @@ function parse_args
# we need absolute dir for PATCH_DIR
cd "${STARTINGDIR}" || cleanup_and_exit 1
if [[ ! -d ${PATCH_DIR} ]]; then
- mkdir -p "${PATCH_DIR}"
- if [[ $? == 0 ]] ; then
+ if mkdir -p "${PATCH_DIR}"; then
echo "${PATCH_DIR} has been created"
else
echo "Unable to create ${PATCH_DIR}"
@@ -1134,15 +1135,11 @@ function find_buildfile_dir
function find_changed_files
{
declare line
- declare oldifs
case "${BUILDMODE}" in
full)
echo "Building a list of all files in the source tree"
- oldifs=${IFS}
- IFS=$'\n'
- CHANGED_FILES=($(git ls-files))
- IFS=${oldifs}
+ while IFS= read -r; do CHANGED_FILES+=("$REPLY"); done < <(git ls-files)
;;
patch)
# get a list of all of the files that have been changed,
@@ -1213,10 +1210,18 @@ function find_changed_modules
declare dirt
declare buildfile
declare -a tmpmods
+ declare retval
- buildfile=$("${BUILDTOOL}_buildfile")
+ if declare -f "${BUILDTOOL}_buildfile" >/dev/null; then
+ buildfile=$("${BUILDTOOL}_buildfile")
+ retval=$?
+ else
+ yetus_error "ERROR: build tool plugin is broken"
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
- if [[ $? != 0 ]]; then
+ if [[ ${retval} != 0 ]]; then
yetus_error "ERROR: Unsupported build tool."
bugsystem_finalreport 1
cleanup_and_exit 1
@@ -1224,7 +1229,7 @@ function find_changed_modules
# Empty string indicates the build system wants to disable module detection
if [[ -z ${buildfile} ]]; then
- tmpmods=(".")
+ CHANGED_MODULES=(".")
else
# Now find all the modules that were changed
@@ -1237,8 +1242,7 @@ function find_changed_modules
dirt=$(dirname "${i}")
- module_skipdir "${dirt}"
- if [[ $? != 0 ]]; then
+ if ! module_skipdir "${dirt}"; then
continue
fi
@@ -1248,15 +1252,16 @@ function find_changed_modules
bugsystem_finalreport 1
cleanup_and_exit 1
fi
- tmpmods=("${tmpmods[@]}" "${builddir}")
+ CHANGED_MODULES+=("${builddir}")
done
fi
- tmpmods=("${tmpmods[@]}" "${USER_MODULE_LIST[@]}")
+ CHANGED_MODULES+=("${USER_MODULE_LIST[@]}")
- CHANGED_MODULES=($(printf "%s\n" "${tmpmods[@]}" | sort -u))
+ yetus_sort_and_unique_array CHANGED_MODULES
yetus_debug "Locate the union of ${CHANGED_MODULES[*]}"
+
count=${#CHANGED_MODULES[@]}
if [[ ${count} -lt 2 ]]; then
yetus_debug "Only one entry, so keeping it ${CHANGED_MODULES[0]}"
@@ -1264,13 +1269,15 @@ function find_changed_modules
CHANGED_UNION_MODULES="${CHANGED_MODULES[0]}"
else
i=1
- while [[ ${i} -lt 100 ]]
- do
+
+ # BUG - fix me
+ # shellcheck disable=SC2207
+ while [[ ${i} -lt 100 ]]; do
tmpmods=()
for j in "${CHANGED_MODULES[@]}"; do
- tmpmods=("${tmpmods[@]}" $(echo "${j}" | cut -f1-${i} -d/))
+ tmpmods+=($(echo "${j}" | cut -f1-${i} -d/))
done
- tmpmods=($(printf "%s\n" "${tmpmods[@]}" | sort -u))
+ tmpmods=($(printf '%s\n' "${tmpmods[@]}" | sort -u))
module=${tmpmods[0]}
count=${#tmpmods[@]}
@@ -1297,7 +1304,7 @@ function find_changed_modules
# some build tools may want to change these and/or
# make other changes based upon these results
- if declare -f ${BUILDTOOL}_reorder_modules >/dev/null; then
+ if declare -f "${BUILDTOOL}_reorder_modules" >/dev/null; then
"${BUILDTOOL}_reorder_modules" "${repostatus}"
fi
}
@@ -1368,7 +1375,7 @@ function git_checkout
# git wiping it out.
exemptdir=$(relative_dir "${PATCH_DIR}")
if [[ $? == 1 ]]; then
- ${GIT} clean -xdf
+ "${GIT}" clean -xdf
status=$?
else
@@ -1377,7 +1384,7 @@ function git_checkout
# re-exec mode (which places a directory full of stuff in it)
yetus_debug "Exempting ${exemptdir} from clean"
rm "${PATCH_DIR}/*" 2>/dev/null
- ${GIT} clean -xdf -e "${exemptdir}"
+ "${GIT}" clean -xdf -e "${exemptdir}"
status=$?
fi
@@ -1420,18 +1427,18 @@ function git_checkout
# protected by OFFLINE == false
if [[ "${GIT_OFFLINE}" == false ]]; then
- if ! ${GIT} fetch; then
+ if ! "${GIT}" fetch; then
yetus_error "ERROR: git fetch is failing"
cleanup_and_exit 1
fi
- if ! ${GIT} reset --hard FETCH_HEAD; then
+ if ! "${GIT}" reset --hard FETCH_HEAD; then
yetus_error "ERROR: git reset is failing"
cleanup_and_exit 1
fi
fi
- if ! ${GIT} clean -df; then
+ if ! "${GIT}" clean -df; then
yetus_error "ERROR: git clean is failing"
cleanup_and_exit 1
fi
@@ -1439,7 +1446,7 @@ function git_checkout
else
- status=$(${GIT} status --porcelain)
+ status=$("${GIT}" status --porcelain)
if [[ "${status}" != "" && -z ${DIRTY_WORKSPACE} ]] ; then
yetus_error "ERROR: --dirty-workspace option not provided."
yetus_error "ERROR: can't run in a workspace that contains the following modifications"
@@ -1449,7 +1456,7 @@ function git_checkout
determine_branch
- currentbranch=$(${GIT} rev-parse --abbrev-ref HEAD)
+ currentbranch=$("${GIT}" rev-parse --abbrev-ref HEAD)
if [[ "${currentbranch}" != "${PATCH_BRANCH}" ]];then
if [[ "${BUILDMODE}" = patch ]]; then
echo "WARNING: Current git branch is ${currentbranch} but patch is built for ${PATCH_BRANCH}."
@@ -1485,8 +1492,7 @@ function verify_valid_branch
if [[ ${check} =~ ^git ]]; then
hash=$(echo "${check}" | cut -f2- -dt)
if [[ -n ${hash} ]]; then
- ${GIT} cat-file -t "${hash}" >/dev/null 2>&1
- if [[ $? -eq 0 ]]; then
+ if "${GIT}" cat-file -t "${hash}" >/dev/null 2>&1; then
PATCH_BRANCH=${hash}
return 0
fi
@@ -1496,7 +1502,7 @@ function verify_valid_branch
fi
fi
- ${GIT} show-ref "${check}" >/dev/null 2>&1
+ "${GIT}" show-ref "${check}" >/dev/null 2>&1
return $?
}
@@ -1516,7 +1522,7 @@ function determine_branch
return
fi
- pushd "${BASEDIR}" > /dev/null
+ pushd "${BASEDIR}" > /dev/null || return 1
yetus_debug "Determine branch"
@@ -1533,7 +1539,7 @@ function determine_branch
fi
for bugs in ${BUGSYSTEMS}; do
- if declare -f ${bugs}_determine_branch >/dev/null;then
+ if declare -f "${bugs}_determine_branch" >/dev/null;then
"${bugs}_determine_branch"
retval=$?
if [[ ${retval} == 0 ]]; then
@@ -1545,7 +1551,7 @@ function determine_branch
if [[ ${retval} != 0 ]]; then
PATCH_BRANCH="${PATCH_BRANCH_DEFAULT}"
fi
- popd >/dev/null
+ popd >/dev/null || return 1
}
## @description Try to guess the issue being tested using a variety of heuristics
@@ -1561,9 +1567,8 @@ function determine_issue
yetus_debug "Determine issue"
for bugsys in ${BUGSYSTEMS}; do
- if declare -f ${bugsys}_determine_issue >/dev/null; then
- "${bugsys}_determine_issue" "${PATCH_OR_ISSUE}"
- if [[ $? == 0 ]]; then
+ if declare -f "${bugsys}_determine_issue" >/dev/null; then
+ if "${bugsys}_determine_issue" "${PATCH_OR_ISSUE}"; then
yetus_debug "${bugsys} says ${ISSUE}"
return 0
fi
@@ -1590,7 +1595,7 @@ function determine_needed_tests
personality_file_tests "${i}"
for plugin in ${TESTTYPES} ${BUILDTOOL}; do
- if declare -f ${plugin}_filefilter >/dev/null 2>&1; then
+ if declare -f "${plugin}_filefilter" >/dev/null 2>&1; then
"${plugin}_filefilter" "${i}"
fi
done
@@ -1609,8 +1614,7 @@ function apply_patch_file
{
big_console_header "Applying patch to ${PATCH_BRANCH}"
- patchfile_apply_driver "${PATCH_DIR}/patch"
- if [[ $? != 0 ]] ; then
+ if ! patchfile_apply_driver "${PATCH_DIR}/patch"; then
echo "PATCH APPLICATION FAILED"
((RESULT = RESULT + 1))
add_vote_table -1 patch "${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}. Rebase required? Wrong Branch? See ${PATCH_NAMING_RULE} for help."
@@ -1644,7 +1648,7 @@ function copytpbits
return
fi
- pushd "${STARTINGDIR}" >/dev/null
+ pushd "${STARTINGDIR}" >/dev/null || return 1
mkdir -p "${PATCH_DIR}/precommit/user-plugins"
mkdir -p "${PATCH_DIR}/precommit/personality"
mkdir -p "${PATCH_DIR}/precommit/test-patch-docker"
@@ -1682,9 +1686,9 @@ function copytpbits
yetus_debug "copying '${DOCKERFILE}' over to '${PATCH_DIR}/precommit/test-patch-docker/Dockerfile'"
dockerdir=$(dirname "${DOCKERFILE}")
dockfile=$(basename "${DOCKERFILE}")
- pushd "${dockerdir}" >/dev/null
+ pushd "${dockerdir}" >/dev/null || return 1
gitfilerev=$("${GIT}" log -n 1 --pretty=format:%h -- "${dockfile}" 2>/dev/null)
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ -z ${gitfilerev} ]]; then
gitfilerev=$(date "+%F")
gitfilerev="date${gitfilerev}"
@@ -1700,16 +1704,16 @@ function copytpbits
fi
# make sure we put some space between, just in case last
# line isn't an empty line or whatever
- printf "\n\n"
+ printf '\n\n'
echo "### YETUS_PRIVATE: start test-patch-bootstrap"
cat "${BINDIR}/test-patch-docker/Dockerfile-endstub"
- printf "\n\n"
+ printf '\n\n'
) > "${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
DOCKERFILE="${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
fi
- popd >/dev/null
+ popd >/dev/null || return 1
}
## @description change the working directory to execute the buildtool
@@ -1729,19 +1733,19 @@ function buildtool_cwd
if [[ ! -e "${BUILDTOOLCWD}" ]]; then
mkdir -p "${BUILDTOOLCWD}"
fi
- pushd "${BUILDTOOLCWD}" >/dev/null
- return $?
+ pushd "${BUILDTOOLCWD}" >/dev/null || return 1
+ return 0
fi
case "${BUILDTOOLCWD}" in
basedir)
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
;;
module)
- pushd "${BASEDIR}/${MODULE[${modindex}]}" >/dev/null
+ pushd "${BASEDIR}/${MODULE[${modindex}]}" >/dev/null || return 1
;;
*)
- pushd "$(pwd)"
+ pushd "$(pwd)" || return 1
;;
esac
}
@@ -1774,6 +1778,7 @@ function check_reexec
"${USER_PLUGIN_DIR}" \
"${DOCKERFILE}"; do
tpdir=$(relative_dir "${testdir}")
+ # shellcheck disable=SC2181
if [[ $? == 0
&& "${CHANGED_FILES[*]}" =~ ${tpdir} ]]; then
copy=true
@@ -2132,13 +2137,11 @@ function modules_workers
fn=$(module_file_fragment "${MODULE[${modindex}]}")
fn="${fn}${jdk}"
modulesuffix=$(basename "${MODULE[${modindex}]}")
- buildtool_cwd "${modindex}"
-
if [[ ${modulesuffix} = \. ]]; then
modulesuffix="root"
fi
- if [[ $? != 0 ]]; then
+ if ! buildtool_cwd "${modindex}"; then
echo "${BASEDIR}/${MODULE[${modindex}]} no longer exists. Skipping."
((modindex=modindex+1))
continue
@@ -2182,7 +2185,7 @@ function modules_workers
MODULE_STATUS_TIMER[${modindex}]=${savestop}
# shellcheck disable=SC2086
echo "Elapsed: $(clock_display ${savestop})"
- popd >/dev/null
+ popd >/dev/null || return 1
((modindex=modindex+1))
done
@@ -2331,7 +2334,7 @@ function check_unittests
needlog=0
for testsys in ${TESTFORMATS}; do
- if declare -f ${testsys}_process_tests >/dev/null; then
+ if declare -f "${testsys}_process_tests" >/dev/null; then
yetus_debug "Calling ${testsys}_process_tests"
"${testsys}_process_tests" "${module}" "${test_logfile}" "${fn}"
formatresult=$?
@@ -2346,13 +2349,13 @@ function check_unittests
module_status ${i} -1 "patch-unit-${fn}.txt"
fi
- popd >/dev/null
+ popd >/dev/null || return 1
((i=i+1))
done
for testsys in ${TESTFORMATS}; do
- if declare -f ${testsys}_finalize_results >/dev/null; then
+ if declare -f "${testsys}_finalize_results" >/dev/null; then
yetus_debug "Calling ${testsys}_finalize_results"
"${testsys}_finalize_results" "${statusjdk}"
fi
@@ -2404,7 +2407,7 @@ function bugsystem_linecomments
uniline=$(${GREP} "${idxline}" "${GITUNIDIFFLINES}" | cut -f3 -d: )
for bugs in ${BUGLINECOMMENTS}; do
- if declare -f ${bugs}_linecomments >/dev/null;then
+ if declare -f "${bugs}_linecomments" >/dev/null;then
"${bugs}_linecomments" "${title}" "${file}" "${realline}" "${uniline}" "${text}"
fi
done
@@ -2428,7 +2431,7 @@ function bugsystem_finalreport
add_footer_table "Powered by" "Apache Yetus ${VERSION} http://yetus.apache.org"
for bugs in ${BUGCOMMENTS}; do
- if declare -f ${bugs}_finalreport >/dev/null;then
+ if declare -f "${bugs}_finalreport" >/dev/null;then
"${bugs}_finalreport" "${@}"
fi
done
@@ -2483,11 +2486,10 @@ function runtests
for plugin in ${TESTTYPES}; do
verify_patchdir_still_exists
- if declare -f ${plugin}_tests >/dev/null 2>&1; then
+ if declare -f "${plugin}_tests" >/dev/null 2>&1; then
modules_reset
yetus_debug "Running ${plugin}_tests"
- #shellcheck disable=SC2086
- ${plugin}_tests
+ "${plugin}_tests"
fi
done
archive
@@ -2514,14 +2516,12 @@ function column_calcdiffs
# accuracy in case of multiple, repeated errors
# since the column number shouldn't change
# if the line of code hasn't been touched
- # shellcheck disable=SC2016
cut -f3- -d: "${branch}" > "${tmp}.branch"
- # shellcheck disable=SC2016
cut -f3- -d: "${patch}" > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
- ${DIFF} --unchanged-line-format="" \
+ "${DIFF}" --unchanged-line-format="" \
--old-line-format="" \
--new-line-format="%dn " \
"${tmp}.branch" \
@@ -2558,14 +2558,14 @@ function error_calcdiffs
# first, pull out just the errors
# shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${branch}" > "${tmp}.branch"
+ "${AWK}" -F: '{print $NF}' "${branch}" > "${tmp}.branch"
# shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${patch}" > "${tmp}.patch"
+ "${AWK}" -F: '{print $NF}' "${patch}" > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
- ${DIFF} --unchanged-line-format="" \
+ "${DIFF}" --unchanged-line-format="" \
--old-line-format="" \
--new-line-format="%dn " \
"${tmp}.branch" \
@@ -2608,11 +2608,11 @@ function calcdiffs
touch "${patchlog}"
fi
- if declare -f ${PROJECT_NAME}_${testtype}_calcdiffs >/dev/null; then
+ if declare -f "${PROJECT_NAME}_${testtype}_calcdiffs" >/dev/null; then
"${PROJECT_NAME}_${testtype}_calcdiffs" "${branchlog}" "${patchlog}"
- elif declare -f ${BUILDTOOL}_${testtype}_calcdiffs >/dev/null; then
+ elif declare -f "${BUILDTOOL}_${testtype}_calcdiffs" >/dev/null; then
"${BUILDTOOL}_${testtype}_calcdiffs" "${branchlog}" "${patchlog}"
- elif declare -f ${testtype}_calcdiffs >/dev/null; then
+ elif declare -f "${testtype}_calcdiffs" >/dev/null; then
"${testtype}_calcdiffs" "${branchlog}" "${patchlog}"
else
error_calcdiffs "${branchlog}" "${patchlog}"
@@ -2663,11 +2663,11 @@ function generic_logfilter
declare input=$2
declare output=$3
- if declare -f ${PROJECT_NAME}_${testtype}_logfilter >/dev/null; then
+ if declare -f "${PROJECT_NAME}_${testtype}_logfilter" >/dev/null; then
"${PROJECT_NAME}_${testtype}_logfilter" "${input}" "${output}"
- elif declare -f ${BUILDTOOL}_${testtype}_logfilter >/dev/null; then
+ elif declare -f "${BUILDTOOL}_${testtype}_logfilter" >/dev/null; then
"${BUILDTOOL}_${testtype}_logfilter" "${input}" "${output}"
- elif declare -f ${testtype}_logfilter >/dev/null; then
+ elif declare -f "${testtype}_logfilter" >/dev/null; then
"${testtype}_logfilter" "${input}" "${output}"
else
yetus_error "ERROR: ${testtype}: No function defined to filter problems."
@@ -2790,9 +2790,9 @@ function generic_postlog_compare
generic_logfilter "${testtype}" "${PATCH_DIR}/patch-${origlog}-${fn}.txt" "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt"
# shellcheck disable=SC2016
- numbranch=$(wc -l "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt" | ${AWK} '{print $1}')
+ numbranch=$(wc -l "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- numpatch=$(wc -l "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt" | ${AWK} '{print $1}')
+ numpatch=$(wc -l "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
calcdiffs \
"${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt" \
@@ -2801,7 +2801,7 @@ function generic_postlog_compare
> "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt"
# shellcheck disable=SC2016
- addpatch=$(wc -l "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt" | ${AWK} '{print $1}')
+ addpatch=$(wc -l "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
((fixedpatch=numbranch-numpatch+addpatch))
@@ -2949,7 +2949,7 @@ function compile_nonjvm
for plugin in ${TESTTYPES}; do
modules_restore
verify_patchdir_still_exists
- if declare -f ${plugin}_compile >/dev/null 2>&1; then
+ if declare -f "${plugin}_compile" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_compile ${codebase} ${multijdkmode}"
"${plugin}_compile" "${codebase}" "${multijdkmode}"
((result = result + $?))
@@ -3010,11 +3010,9 @@ function compile_cycle
find_changed_modules "${codebase}"
for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_precompile >/dev/null 2>&1; then
+ if declare -f "${plugin}_precompile" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_precompile"
- #shellcheck disable=SC2086
- ${plugin}_precompile ${codebase}
- if [[ $? -gt 0 ]]; then
+ if ! "${plugin}_precompile" "${codebase}"; then
((result = result+1))
fi
archive
@@ -3024,11 +3022,9 @@ function compile_cycle
compile "${codebase}"
for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_postcompile >/dev/null 2>&1; then
+ if declare -f "${plugin}_postcompile" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_postcompile"
- #shellcheck disable=SC2086
- ${plugin}_postcompile ${codebase}
- if [[ $? -gt 0 ]]; then
+ if ! "${plugin}_postcompile" "${codebase}"; then
((result = result+1))
fi
archive
@@ -3036,11 +3032,9 @@ function compile_cycle
done
for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_rebuild >/dev/null 2>&1; then
+ if declare -f "${plugin}_rebuild" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_rebuild"
- #shellcheck disable=SC2086
- ${plugin}_rebuild ${codebase}
- if [[ $? -gt 0 ]]; then
+ if ! "${plugin}_rebuild" "${codebase}"; then
((result = result+1))
fi
archive
@@ -3067,11 +3061,9 @@ function patchfiletests
declare result=0
for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_patchfile >/dev/null 2>&1; then
+ if declare -f "${plugin}_patchfile" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_patchfile"
- #shellcheck disable=SC2086
- ${plugin}_patchfile "${PATCH_DIR}/patch"
- if [[ $? -gt 0 ]]; then
+ if ! "${plugin}_patchfile" "${PATCH_DIR}/patch"; then
((result = result+1))
fi
archive
@@ -3099,11 +3091,9 @@ function distclean
big_console_header "Cleaning the source tree"
for plugin in ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_clean >/dev/null 2>&1; then
+ if declare -f "${plugin}_clean" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_distclean"
- #shellcheck disable=SC2086
- ${plugin}_clean
- if [[ $? -gt 0 ]]; then
+ if ! "${plugin}_clean"; then
((result = result+1))
fi
fi
@@ -3238,8 +3228,7 @@ function initialize
echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
fi
- patchfile_dryrun_driver "${PATCH_DIR}/patch"
- if [[ $? != 0 ]]; then
+ if ! patchfile_dryrun_driver "${PATCH_DIR}/patch"; then
((RESULT = RESULT + 1))
yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
add_vote_table -1 patch "${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}. Rebase required? Wrong Branch? See ${PATCH_NAMING_RULE} for help."
@@ -3276,11 +3265,10 @@ function prechecks
for plugin in ${BUILDTOOL} ${NEEDED_TESTS} ${TESTFORMATS}; do
verify_patchdir_still_exists
- if declare -f ${plugin}_precheck >/dev/null 2>&1; then
+ if declare -f "${plugin}_precheck" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_precheck"
- #shellcheck disable=SC2086
- ${plugin}_precheck
+ "${plugin}_precheck"
(( result = result + $? ))
if [[ ${result} != 0 ]] ; then
@@ -3375,4 +3363,3 @@ finish_footer_table
bugsystem_finalreport ${RESULT}
cleanup_and_exit ${RESULT}
-
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/yetus-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/yetus-maven-plugin/pom.xml b/yetus-maven-plugin/pom.xml
index 13072d4..a73f709 100644
--- a/yetus-maven-plugin/pom.xml
+++ b/yetus-maven-plugin/pom.xml
@@ -78,7 +78,9 @@
</goals>
<configuration>
<sources>
- <source>../yetus-minimaven-plugin/src/main</source>
+ <source>../yetus-minimaven-plugin/src/main/resources</source>
+ <source>../yetus-minimaven-plugin/src/main/java/org/apache/yetus/maven/plugin/fileops/MakeBins4Libs.java</source>
+ <source>../yetus-minimaven-plugin/src/main/java/org/apache/yetus/maven/plugin/fileops/CreateSymLinkMojo.java</source>
</sources>
</configuration>
</execution>
[3/3] yetus git commit: YETUS-720. github/jira bridge collapses when
jira issues list isn't defined
Posted by aw...@apache.org.
YETUS-720. github/jira bridge collapses when jira issues list isn't defined
Signed-off-by: Allen Wittenauer <aw...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/1fcaabd4
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/1fcaabd4
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/1fcaabd4
Branch: refs/heads/master
Commit: 1fcaabd4ea91ca7f0b5acd67febcb0cc62ea568d
Parents: 9a2cd58
Author: Allen Wittenauer <aw...@apache.org>
Authored: Thu Nov 15 14:59:13 2018 -0800
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Thu Dec 13 08:22:12 2018 -0800
----------------------------------------------------------------------
precommit/src/main/shell/test-patch.d/jira.sh | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/1fcaabd4/precommit/src/main/shell/test-patch.d/jira.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/jira.sh b/precommit/src/main/shell/test-patch.d/jira.sh
index 00c7a54..cb2b53a 100755
--- a/precommit/src/main/shell/test-patch.d/jira.sh
+++ b/precommit/src/main/shell/test-patch.d/jira.sh
@@ -90,6 +90,10 @@ function jira_determine_issue
return 0
fi
+ if [[ -z "${JIRA_ISSUE_RE}" ]]; then
+ return 1
+ fi
+
# shellcheck disable=SC2016
patchnamechunk=$(echo "${input}" | "${AWK}" -F/ '{print $NF}')
[2/3] yetus git commit: YETUS-708. Clean up the source
Posted by aw...@apache.org.
YETUS-708. Clean up the source
Signed-off-by: Allen Wittenauer <aw...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/9a2cd581
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/9a2cd581
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/9a2cd581
Branch: refs/heads/master
Commit: 9a2cd5817d924fa712ca9575537ee1e95feca16b
Parents: 492a20e
Author: Allen Wittenauer <aw...@apache.org>
Authored: Wed Oct 10 22:06:48 2018 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Thu Dec 13 08:16:35 2018 -0800
----------------------------------------------------------------------
asf-site-src/source/contribute/releases.md | 2 +-
hooks/build | 12 +-
precommit/src/main/shell/core.d/00-yetuslib.sh | 43 +++-
precommit/src/main/shell/core.d/01-common.sh | 20 +-
.../src/main/shell/core.d/builtin-bugsystem.sh | 30 +--
precommit/src/main/shell/core.d/docker.sh | 14 +-
precommit/src/main/shell/core.d/patchfiles.sh | 46 ++--
precommit/src/main/shell/core.d/reaper.sh | 4 +-
precommit/src/main/shell/docker-cleanup.sh | 6 +-
precommit/src/main/shell/personality/flink.sh | 9 +-
precommit/src/main/shell/personality/hadoop.sh | 12 +-
precommit/src/main/shell/personality/hbase.sh | 4 +-
precommit/src/main/shell/personality/jmeter.sh | 4 +-
precommit/src/main/shell/personality/kafka.sh | 4 +-
precommit/src/main/shell/smart-apply-patch.sh | 40 ++--
precommit/src/main/shell/test-patch.d/ant.sh | 8 +-
.../src/main/shell/test-patch.d/asflicense.sh | 19 +-
.../src/main/shell/test-patch.d/autoconf.sh | 8 +-
.../src/main/shell/test-patch.d/bugzilla.sh | 14 +-
precommit/src/main/shell/test-patch.d/cc.sh | 10 +-
.../src/main/shell/test-patch.d/checkstyle.sh | 25 ++-
precommit/src/main/shell/test-patch.d/cmake.sh | 2 +-
.../src/main/shell/test-patch.d/dupname.sh | 2 +-
.../src/main/shell/test-patch.d/findbugs.sh | 57 ++---
precommit/src/main/shell/test-patch.d/github.sh | 29 ++-
precommit/src/main/shell/test-patch.d/gradle.sh | 15 +-
.../src/main/shell/test-patch.d/hadolint.sh | 16 +-
.../src/main/shell/test-patch.d/htmlout.sh | 10 +-
precommit/src/main/shell/test-patch.d/java.sh | 2 +
precommit/src/main/shell/test-patch.d/jira.sh | 42 ++--
precommit/src/main/shell/test-patch.d/junit.sh | 6 +-
precommit/src/main/shell/test-patch.d/make.sh | 2 +-
precommit/src/main/shell/test-patch.d/maven.sh | 60 +++--
.../src/main/shell/test-patch.d/nobuild.sh | 4 +
.../src/main/shell/test-patch.d/perlcritic.sh | 18 +-
.../src/main/shell/test-patch.d/rubocop.sh | 24 +-
.../src/main/shell/test-patch.d/ruby-lint.sh | 31 ++-
precommit/src/main/shell/test-patch.d/scala.sh | 8 +-
.../src/main/shell/test-patch.d/shellcheck.sh | 12 +-
.../src/main/shell/test-patch.d/shelldocs.sh | 23 +-
precommit/src/main/shell/test-patch.d/tap.sh | 2 +
.../src/main/shell/test-patch.d/unitveto.sh | 2 +
.../src/main/shell/test-patch.d/whitespace.sh | 9 +-
precommit/src/main/shell/test-patch.d/xml.sh | 6 +-
precommit/src/main/shell/test-patch.sh | 225 +++++++++----------
yetus-maven-plugin/pom.xml | 4 +-
46 files changed, 520 insertions(+), 425 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/asf-site-src/source/contribute/releases.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/contribute/releases.md b/asf-site-src/source/contribute/releases.md
index f3c459e..6e802f8 100644
--- a/asf-site-src/source/contribute/releases.md
+++ b/asf-site-src/source/contribute/releases.md
@@ -359,7 +359,7 @@ If you've gone through all of the ASF required checks, you'll already have made
============================================================================
| 0 | reexec | 0m 0s | Docker mode activated.
| +1 | hbaseanti | 0m 0s | Patch does not have any anti-patterns.
- | +1 | @author | 0m 0s | The patch does not contain any @author
+ | +1 | @\author | 0m 0s | The patch does not contain any @\author
| | | | tags.
| +1 | test4tests | 0m 0s | The patch appears to include 2 new or
| | | | modified test files.
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/hooks/build
----------------------------------------------------------------------
diff --git a/hooks/build b/hooks/build
index 21876dc..531cf76 100755
--- a/hooks/build
+++ b/hooks/build
@@ -16,12 +16,12 @@
if [[ -n "${DOCKERFILE_PATH}" ]]; then
docker build -t "${IMAGE_NAME}" \
- --build-arg DOCKER_TAG="${DOCKER_TAG}" \
- --build-arg DOCKER_REPO="${DOCKER_REPO}" \
- -f "${DOCKERFILE_PATH}"
+ --build-arg DOCKER_TAG="${DOCKER_TAG}" \
+ --build-arg DOCKER_REPO="${DOCKER_REPO}" \
+ -f "${DOCKERFILE_PATH}"
else
docker build -t "${IMAGE_NAME}" \
- --build-arg DOCKER_TAG="${DOCKER_TAG}" \
- --build-arg DOCKER_REPO="${DOCKER_REPO}" \
- .
+ --build-arg DOCKER_TAG="${DOCKER_TAG}" \
+ --build-arg DOCKER_REPO="${DOCKER_REPO}" \
+ .
fi
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/00-yetuslib.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/00-yetuslib.sh b/precommit/src/main/shell/core.d/00-yetuslib.sh
index 983dfe6..27d169f 100755
--- a/precommit/src/main/shell/core.d/00-yetuslib.sh
+++ b/precommit/src/main/shell/core.d/00-yetuslib.sh
@@ -123,6 +123,7 @@ function yetus_abs
fi
dir=$(cd -P -- "${dir}" >/dev/null 2>/dev/null && pwd -P)
+ #shellcheck disable=SC2181
if [[ $? = 0 ]]; then
echo "${dir}${fn}"
return 0
@@ -220,7 +221,7 @@ function yetus_generic_columnprinter
giventext=$(echo "${tmpa[$i]}" | cut -f2 -d'@')
while read -r line; do
- printf "%-${maxoptsize}s %-s\n" "${option}" "${line}"
+ printf "%-${maxoptsize}s %-s\\n" "${option}" "${line}"
option=" "
done < <(echo "${giventext}"| fold -s -w ${foldsize})
((i=i+1))
@@ -239,6 +240,7 @@ function yetus_comma_to_array
declare string=$2
oldifs="${IFS}"
+ #shellcheck disable=SC2229
IFS=',' read -r -a "${var}" <<< "${string}"
IFS="${oldifs}"
}
@@ -314,7 +316,7 @@ function yetus_sort_array
oifs=${IFS}
fi
set -f
- # shellcheck disable=SC2034
+ # shellcheck disable=SC2034,SC2207
IFS=$'\n' sa=($(sort <<<"${array[*]}"))
# shellcheck disable=SC1083
eval "${arrname}"=\(\"\${sa[@]}\"\)
@@ -329,3 +331,40 @@ function yetus_sort_array
set +f
fi
}
+
+## @description Sort and unique an array by its elements
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param arrayvar
+function yetus_sort_and_unique_array
+{
+ declare arrname=$1
+ declare arrref="${arrname}[@]"
+ declare array=("${!arrref}")
+
+ declare globstatus
+ declare oifs
+ declare -a sa
+
+ globstatus=$(set -o | grep noglob | awk '{print $NF}')
+
+ if [[ -n ${IFS} ]]; then
+ oifs=${IFS}
+ fi
+ set -f
+ # shellcheck disable=SC2034,SC2207
+ IFS=$'\n' sa=($(sort -u <<<"${array[*]}"))
+ # shellcheck disable=SC1083
+ eval "${arrname}"=\(\"\${sa[@]}\"\)
+
+ if [[ -n "${oifs}" ]]; then
+ IFS=${oifs}
+ else
+ unset IFS
+ fi
+
+ if [[ "${globstatus}" = off ]]; then
+ set +f
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/01-common.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/01-common.sh b/precommit/src/main/shell/core.d/01-common.sh
index 67d2e46..de027e5 100755
--- a/precommit/src/main/shell/core.d/01-common.sh
+++ b/precommit/src/main/shell/core.d/01-common.sh
@@ -219,14 +219,14 @@ function common_args
# git apply or don't support all the
# expected options
version=$(${GIT} --version)
-
+ # shellcheck disable=SC2181
if [[ $? != 0 ]]; then
yetus_error "ERROR: ${GIT} failed during version detection."
exit 1
fi
# shellcheck disable=SC2016
- version=$(echo "${version}" | ${AWK} '{print $NF}')
+ version=$(echo "${version}" | "${AWK}" '{print $NF}')
if [[ ${version} =~ ^0
|| ${version} =~ ^1.[0-6]
|| ${version} =~ ^1.7.[0-2]$
@@ -249,9 +249,9 @@ function list_plugins
ENABLED_PLUGINS="all"
importplugins
- printf "Reminder: every plug-in may be enabled via 'all'.\n\n"
+ printf "Reminder: every plug-in may be enabled via 'all'.\\n\\n"
for plugintype in BUILDTOOLS TESTTYPES BUGSYSTEMS TESTFORMATS; do
- printf "%s:\n\t" ${plugintype}
+ printf '%s:\n\t' ${plugintype}
for name in ${!plugintype}; do
printf "%s " ${name}
done
@@ -270,8 +270,7 @@ function parse_args_plugins
for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_parse_args"
- #shellcheck disable=SC2086
- ${plugin}_parse_args "$@"
+ "${plugin}_parse_args" "$@"
(( RESULT = RESULT + $? ))
fi
done
@@ -288,8 +287,7 @@ function plugins_initialize
for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOL}; do
if declare -f ${plugin}_initialize >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_initialize"
- #shellcheck disable=SC2086
- ${plugin}_initialize
+ "${plugin}_initialize"
(( RESULT = RESULT + $? ))
fi
done
@@ -487,15 +485,19 @@ function importplugins
local plugin
local files=()
+ #BUG: this will break horribly if there are spaces in the paths. :(
+
if [[ ${LOAD_SYSTEM_PLUGINS} == "true" ]]; then
if [[ -d "${BINDIR}/test-patch.d" ]]; then
+ #shellcheck disable=SC2206
files=(${BINDIR}/test-patch.d/*.sh)
fi
fi
if [[ -n "${USER_PLUGIN_DIR}" && -d "${USER_PLUGIN_DIR}" ]]; then
yetus_debug "Loading user provided plugins from ${USER_PLUGIN_DIR}"
- files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
+ #shellcheck disable=SC2206
+ files+=(${USER_PLUGIN_DIR}/*.sh)
fi
if [[ -n ${PERSONALITY} && ! -f ${PERSONALITY} ]]; then
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/builtin-bugsystem.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/builtin-bugsystem.sh b/precommit/src/main/shell/core.d/builtin-bugsystem.sh
index 0aeddf1..a20ccc4 100755
--- a/precommit/src/main/shell/core.d/builtin-bugsystem.sh
+++ b/precommit/src/main/shell/core.d/builtin-bugsystem.sh
@@ -53,7 +53,7 @@ function console_finalreport
if [[ ${result} == 0 ]]; then
if [[ ${ROBOT} == false ]]; then
- if declare -f ${PROJECT_NAME}_console_success >/dev/null; then
+ if declare -f "${PROJECT_NAME}_console_success" >/dev/null; then
"${PROJECT_NAME}_console_success" > "${spcfx}"
else
{
@@ -66,10 +66,10 @@ function console_finalreport
} > "${spcfx}"
fi
fi
- printf "\n\n+1 overall\n\n"
+ printf '\n\n+1 overall\n\n'
else
if [[ ${ROBOT} == false ]]; then
- if declare -f ${PROJECT_NAME}_console_failure >/dev/null; then
+ if declare -f "${PROJECT_NAME}_console_failure" >/dev/null; then
"${PROJECT_NAME}_console_failure" > "${spcfx}"
else
{
@@ -81,13 +81,13 @@ function console_finalreport
} > "${spcfx}"
fi
fi
- printf "\n\n-1 overall\n\n"
+ printf '\n\n-1 overall\n\n'
fi
if [[ -f ${spcfx} ]]; then
- if which base64 >/dev/null 2>&1; then
+ if command -v base64 >/dev/null 2>&1; then
base64 --decode "${spcfx}" 2>/dev/null
- elif which openssl >/dev/null 2>&1; then
+ elif command -v openssl >/dev/null 2>&1; then
openssl enc -A -d -base64 -in "${spcfx}" 2>/dev/null
fi
echo
@@ -103,11 +103,11 @@ function console_finalreport
seccoladj=$((seccoladj + 2 ))
i=0
until [[ $i -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n" "${TP_HEADER[${i}]}"
+ printf '%s\n' "${TP_HEADER[${i}]}"
((i=i+1))
done
- printf "| %s | %*s | %s | %s\n" "Vote" ${seccoladj} Subsystem Runtime "Comment"
+ printf '| %s | %*s | %s | %s\n' "Vote" ${seccoladj} Subsystem Runtime "Comment"
echo "============================================================================"
i=0
until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
@@ -123,13 +123,13 @@ function console_finalreport
${SED} -e '1d' "${commentfile1}" > "${commentfile2}"
if [[ "${vote}" = "H" ]]; then
- printf "| | %*s | |%-s\n" ${seccoladj} " " "${normaltop}"
+ printf '| | %*s | |%-s\n' ${seccoladj} " " "${normaltop}"
else
- printf "| %4s | %*s | %-10s |%-s\n" "${vote}" ${seccoladj} \
+ printf '| %4s | %*s | %-10s |%-s\n' "${vote}" ${seccoladj} \
"${subs}" "${calctime}" "${normaltop}"
fi
while read -r line; do
- printf "| | %*s | | %-s\n" ${seccoladj} " " "${line}"
+ printf '| | %*s | | %-s\n' ${seccoladj} " " "${line}"
done < "${commentfile2}"
((i=i+1))
@@ -138,18 +138,18 @@ function console_finalreport
if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
seccoladj=$(findlargest 1 "${TP_TEST_TABLE[@]}")
- printf "\n\n%*s | Tests\n" "${seccoladj}" "Reason"
+ printf '\n\n%*s | Tests\n' "${seccoladj}" "Reason"
i=0
until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
ourstring=$(echo "${TP_TEST_TABLE[${i}]}" | tr -s ' ')
vote=$(echo "${ourstring}" | cut -f2 -d\|)
subs=$(echo "${ourstring}" | cut -f3 -d\|)
- printf "%*s | %s\n" "${seccoladj}" "${vote}" "${subs}"
+ printf '%*s | %s\n' "${seccoladj}" "${vote}" "${subs}"
((i=i+1))
done
fi
- printf "\n\n|| Subsystem || Report/Notes ||\n"
+ printf '\n\n|| Subsystem || Report/Notes ||\n'
echo "============================================================================"
i=0
@@ -162,7 +162,7 @@ function console_finalreport
comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
${SED} -e "s,@@BASE@@,${PATCH_DIR},g")
fi
- printf "%s\n" "${comment}"
+ printf '%s\n' "${comment}"
((i=i+1))
done
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/docker.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/docker.sh b/precommit/src/main/shell/core.d/docker.sh
index a9d0745..794e610 100755
--- a/precommit/src/main/shell/core.d/docker.sh
+++ b/precommit/src/main/shell/core.d/docker.sh
@@ -15,7 +15,7 @@
# limitations under the License.
DOCKERMODE=false
-DOCKERCMD=$(command -v docker)
+DOCKERCMD=$(command -v docker 2>/dev/null)
DOCKER_ID=${RANDOM}
DOCKER_DESTRUCTIVE=true
DOCKERFILE_DEFAULT="${BINDIR}/test-patch-docker/Dockerfile"
@@ -182,7 +182,7 @@ function docker_fileverify
if [[ ${DOCKERMODE} = false &&
${DOCKERSUPPORT} = true ]]; then
if [[ -n "${DOCKERFILE}" ]]; then
- pushd "${STARTINGDIR}" >/dev/null
+ pushd "${STARTINGDIR}" >/dev/null || return 1
if [[ -f ${DOCKERFILE} ]]; then
DOCKERFILE=$(yetus_abs "${DOCKERFILE}")
else
@@ -201,7 +201,7 @@ function docker_fileverify
cleanup_and_exit 1
fi
fi
- popd >/dev/null
+ popd >/dev/null || return 1
else
DOCKERFILE=${DOCKERFILE_DEFAULT}
fi
@@ -450,9 +450,9 @@ function docker_image_maintenance
# repostory:tag and send that to get removed.
#shellcheck disable=SC2046,SC2016
- docker_image_maintenance_helper $(dockercmd images | ${GREP} -e ^yetus | grep tp- | ${AWK} '{print $1":"$2}')
+ docker_image_maintenance_helper $(dockercmd images | "${GREP}" -e ^yetus | "${GREP}" tp- | "${AWK}" '{print $1":"$2}')
#shellcheck disable=SC2046,SC2016
- docker_image_maintenance_helper $(dockercmd images | ${GREP} -e ^yetus | ${GREP} -v hours | ${AWK} '{print $1":"$2}')
+ docker_image_maintenance_helper $(dockercmd images | "${GREP}" -e ^yetus | "${GREP}" -v hours | "${AWK}" '{print $1":"$2}')
if [[ "${SENTINEL}" = false ]]; then
return
@@ -491,6 +491,10 @@ function docker_getfilerev
| cut -f2 -d=
}
+## @description determine the docker version
+## @stability stable
+## @audience private
+## @replaceable no
function docker_version
{
declare vertype=$1
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/patchfiles.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/patchfiles.sh b/precommit/src/main/shell/core.d/patchfiles.sh
index 9a17876..381573c 100755
--- a/precommit/src/main/shell/core.d/patchfiles.sh
+++ b/precommit/src/main/shell/core.d/patchfiles.sh
@@ -31,10 +31,9 @@ function generic_locate_patch
return 1
fi
- ${CURL} --silent -L \
+ if ! ${CURL} --silent -L \
--output "${output}" \
- "${input}"
- if [[ $? != 0 ]]; then
+ "${input}"; then
yetus_debug "generic_locate_patch: failed to download the patch."
return 1
fi
@@ -65,6 +64,7 @@ function guess_patch_file
fi
fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
+ #shellcheck disable=SC2181
if [[ $? == 0 ]]; then
yetus_debug "first line looks like a patch file."
return 0
@@ -107,9 +107,8 @@ function locate_patch
else
# run through the bug systems. maybe they know?
for bugsys in ${BUGSYSTEMS}; do
- if declare -f ${bugsys}_locate_patch >/dev/null 2>&1; then
- "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
- if [[ $? == 0 ]]; then
+ if declare -f "${bugsys}_locate_patch" >/dev/null 2>&1; then
+ if "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"; then
gotit=true
PATCH_SYSTEM=${bugsys}
fi
@@ -122,8 +121,7 @@ function locate_patch
# ok, none of the bug systems know. let's see how smart we are
if [[ ${gotit} == false ]]; then
- generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
- if [[ $? != 0 ]]; then
+ if ! generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"; then
yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
cleanup_and_exit 1
fi
@@ -135,8 +133,7 @@ function locate_patch
if [[ ! -f "${PATCH_DIR}/patch"
&& -f "${patchfile}" ]]; then
- cp "${patchfile}" "${PATCH_DIR}/patch"
- if [[ $? == 0 ]] ; then
+ if cp "${patchfile}" "${PATCH_DIR}/patch"; then
echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
else
yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
@@ -163,15 +160,15 @@ function patchfile_verify_zero
# don't return /dev/null
# shellcheck disable=SC2016
- changed_files1=$(${AWK} 'function p(s){if(s!~"^/dev/null"){print s}}
+ changed_files1=$("${AWK}" 'function p(s){if(s!~"^/dev/null"){print s}}
/^diff --git / { p($3); p($4) }
/^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
# maybe we interpreted the patch wrong? check the log file
# shellcheck disable=SC2016
- changed_files2=$(${GREP} -E '^[cC]heck' "${logfile}" \
- | ${AWK} '{print $3}' \
- | ${SED} -e 's,\.\.\.$,,g')
+ changed_files2=$("${GREP}" -E '^[cC]heck' "${logfile}" \
+ | "${AWK}" '{print $3}' \
+ | "${SED}" -e 's,\.\.\.$,,g')
for filename in ${changed_files1} ${changed_files2}; do
@@ -209,9 +206,8 @@ function gitapply_dryrun
while [[ ${prefixsize} -lt 4
&& -z ${PATCH_METHOD} ]]; do
- yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
- "${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"
- if [[ $? == 0 ]]; then
+ if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ "${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"; then
PATCH_LEVEL=${prefixsize}
PATCH_METHOD=gitapply
break
@@ -220,8 +216,7 @@ function gitapply_dryrun
done
if [[ ${prefixsize} -eq 0 ]]; then
- patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
- if [[ $? != 0 ]]; then
+ if ! patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"; then
PATCH_METHOD=""
PATCH_LEVEL=""
gitapply_dryrun "${patchfile}" 1
@@ -242,9 +237,8 @@ function patchcmd_dryrun
while [[ ${prefixsize} -lt 4
&& -z ${PATCH_METHOD} ]]; do
# shellcheck disable=SC2153
- yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
- "${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"
- if [[ $? == 0 ]]; then
+ if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ "${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"; then
PATCH_LEVEL=${prefixsize}
PATCH_METHOD=patchcmd
break
@@ -253,8 +247,7 @@ function patchcmd_dryrun
done
if [[ ${prefixsize} -eq 0 ]]; then
- patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
- if [[ $? != 0 ]]; then
+ if ! patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"; then
PATCH_METHOD=""
PATCH_LEVEL=""
patchcmd_dryrun "${patchfile}" 1
@@ -274,7 +267,7 @@ function patchfile_dryrun_driver
#shellcheck disable=SC2153
for method in "${PATCH_METHODS[@]}"; do
- if declare -f ${method}_dryrun >/dev/null; then
+ if declare -f "${method}_dryrun" >/dev/null; then
"${method}_dryrun" "${patchfile}"
fi
if [[ -n ${PATCH_METHOD} ]]; then
@@ -334,8 +327,7 @@ function patchfile_apply_driver
declare gpg=$2
if declare -f ${PATCH_METHOD}_apply >/dev/null; then
- "${PATCH_METHOD}_apply" "${patchfile}" "${gpg}"
- if [[ $? -gt 0 ]]; then
+ if ! "${PATCH_METHOD}_apply" "${patchfile}" "${gpg}"; then
return 1
fi
else
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/core.d/reaper.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/core.d/reaper.sh b/precommit/src/main/shell/core.d/reaper.sh
index ce48c25..8859274 100755
--- a/precommit/src/main/shell/core.d/reaper.sh
+++ b/precommit/src/main/shell/core.d/reaper.sh
@@ -194,14 +194,14 @@ function reaper_post_exec
sleep 2
#shellcheck disable=SC2154,SC2086
- printf "reap\n%s\n%s\n" "${module}" "${myfile}" >&${reaper_coproc[1]}
+ printf 'reap\n%s\n%s\n' "${module}" "${myfile}" >&${reaper_coproc[1]}
#shellcheck disable=SC2154,SC2086
read -r count <&${reaper_coproc[0]}
if [[ ${count} -gt 0 ]]; then
((REAPER_TOTAL_COUNT=REAPER_TOTAL_COUNT+count))
- printf "\nFound%s %s left over processes\n\n" "${killmsg}" "${count}"
+ printf '\nFound%s %s left over processes\n\n' "${killmsg}" "${count}"
REAPER_ZOMBIE_MODULES+=("${module}:${count}")
REAPER_ZOMBIE_LOGS+=("@@BASE@@/${myfile}")
return 1
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/docker-cleanup.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/docker-cleanup.sh b/precommit/src/main/shell/docker-cleanup.sh
index 1d17b1b..e6515e5 100755
--- a/precommit/src/main/shell/docker-cleanup.sh
+++ b/precommit/src/main/shell/docker-cleanup.sh
@@ -176,13 +176,13 @@ function big_console_header
{
local text="$*"
local spacing=$(( (75+${#text}) /2 ))
- printf "\n\n"
+ printf '\n\n'
echo "============================================================================"
echo "============================================================================"
- printf "%*s\n" ${spacing} "${text}"
+ printf '%*s\n' ${spacing} "${text}"
echo "============================================================================"
echo "============================================================================"
- printf "\n\n"
+ printf '\n\n'
}
trap "cleanup_and_exit 1" HUP INT QUIT TERM
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/personality/flink.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/personality/flink.sh b/precommit/src/main/shell/personality/flink.sh
index a9c0fdf..971783a 100755
--- a/precommit/src/main/shell/personality/flink.sh
+++ b/precommit/src/main/shell/personality/flink.sh
@@ -75,10 +75,9 @@ function flinklib_rebuild
return 0
fi
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/${repostatus}-flinklib-root.txt" \
- "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch
- if [[ $? != 0 ]]; then
+ pushd "${BASEDIR}" >/dev/null || return 1
+ if ! echo_and_redirect "${PATCH_DIR}/${repostatus}-flinklib-root.txt" \
+ "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch; then
add_vote_table -1 flinklib "Unable to determine flink libs in ${PATCH_BRANCH}."
fi
@@ -88,7 +87,7 @@ function flinklib_rebuild
else
FLINK_POST_LIB_FILES=$(flinklib_count)
fi
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ "${BUILDMODE}" = full ]]; then
if [[ ${FLINK_POST_LIB_FILES} -gt 0 ]]; then
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/personality/hadoop.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/personality/hadoop.sh b/precommit/src/main/shell/personality/hadoop.sh
index 2ad4459..5323cc0 100755
--- a/precommit/src/main/shell/personality/hadoop.sh
+++ b/precommit/src/main/shell/personality/hadoop.sh
@@ -162,11 +162,11 @@ function hadoop_unittest_prereqs
module="hadoop-common-project/hadoop-common"
fn=$(module_file_fragment "${module}")
flags="$(hadoop_native_flags) $(yarn_ui2_flag)"
- pushd "${BASEDIR}/${module}" >/dev/null
+ pushd "${BASEDIR}/${module}" >/dev/null || return 1
# shellcheck disable=SC2086
echo_and_redirect "${PATCH_DIR}/maven-unit-prereq-${fn}-install.txt" \
"${MAVEN}" "${MAVEN_ARGS[@]}" install -DskipTests ${flags}
- popd >/dev/null
+ popd >/dev/null || return 1
fi
}
@@ -328,11 +328,11 @@ function personality_modules
for i in hadoop-project \
hadoop-common-project/hadoop-annotations; do
fn=$(module_file_fragment "${i}")
- pushd "${BASEDIR}/${i}" >/dev/null
+ pushd "${BASEDIR}/${i}" >/dev/null || return 1
echo "cd ${i}"
echo_and_redirect "${PATCH_DIR}/maven-${fn}-install.txt" \
"${MAVEN}" "${MAVEN_ARGS[@]}" install
- popd >/dev/null
+ popd >/dev/null || return 1
done
fi
extra="-Pdocs -DskipTests"
@@ -537,7 +537,7 @@ function shadedclient_rebuild
hadoop-client-modules/hadoop-client-integration-tests; do
if [ -d "${module}" ]; then
yetus_debug "hadoop personality: test module '${module}' is present."
- modules=( ${modules[@]} -pl ${module} )
+ modules+=(-pl "${module}")
fi
done
if [ ${#modules[@]} -eq 0 ]; then
@@ -552,7 +552,7 @@ function shadedclient_rebuild
"${modules[@]}" \
-Dtest=NoUnitTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true
- count=$(${GREP} -c '\[ERROR\]' "${logfile}")
+ count=$("${GREP}" -c '\[ERROR\]' "${logfile}")
if [[ ${count} -gt 0 ]]; then
add_vote_table -1 shadedclient "${repostatus} has errors when building and testing our client artifacts."
return 1
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/personality/hbase.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/personality/hbase.sh b/precommit/src/main/shell/personality/hbase.sh
index b48691e..5de4305 100755
--- a/precommit/src/main/shell/personality/hbase.sh
+++ b/precommit/src/main/shell/personality/hbase.sh
@@ -275,13 +275,13 @@ function hbaseanti_patchfile
start_clock
- warnings=$(${GREP} 'new TreeMap<byte.*()' "${patchfile}")
+ warnings=$("${GREP}" 'new TreeMap<byte.*()' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears to have anti-pattern where BYTES_COMPARATOR was omitted: ${warnings}."
((result=result+1))
fi
- warnings=$(${GREP} 'import org.apache.hadoop.classification' "${patchfile}")
+ warnings=$("${GREP}" 'import org.apache.hadoop.classification' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears use Hadoop classification instead of HBase: ${warnings}."
((result=result+1))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/personality/jmeter.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/personality/jmeter.sh b/precommit/src/main/shell/personality/jmeter.sh
index b4e61b5..cb2cb1a 100755
--- a/precommit/src/main/shell/personality/jmeter.sh
+++ b/precommit/src/main/shell/personality/jmeter.sh
@@ -64,8 +64,8 @@ function jmeter_parse_args
function jmeter_precheck
{
if [[ ${JMETER_DOWNLOAD_JARS} = true ]]; then
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
echo_and_redirect "${PATCH_DIR}/jmeter-branch-download-jars.txt" "${ANT}" download_jars
- popd >/dev/null
+ popd >/dev/null || return 1
fi
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/personality/kafka.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/personality/kafka.sh b/precommit/src/main/shell/personality/kafka.sh
index 0c2f749..ceb2604 100755
--- a/precommit/src/main/shell/personality/kafka.sh
+++ b/precommit/src/main/shell/personality/kafka.sh
@@ -54,9 +54,9 @@ function personality_modules
gradleboot)
# kafka's bootstrap is broken
if [[ ${testtype} == gradleboot ]]; then
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
echo_and_redirect "${PATCH_DIR}/kafka-configure-gradle.txt" gradle
- popd >/dev/null
+ popd >/dev/null || return 1
fi
;;
compile)
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/smart-apply-patch.sh b/precommit/src/main/shell/smart-apply-patch.sh
index a5dd09b..bf44a8f 100755
--- a/precommit/src/main/shell/smart-apply-patch.sh
+++ b/precommit/src/main/shell/smart-apply-patch.sh
@@ -28,22 +28,37 @@ BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
#shellcheck disable=SC2034
QATESTMODE=false
-# dummy functions
+## @description disable function
+## @stability stable
+## @audience private
+## @replaceable no
function add_vote_table
{
true
}
+## @description disable function
+## @stability stable
+## @audience private
+## @replaceable no
function add_footer_table
{
true
}
+## @description disable function
+## @stability stable
+## @audience private
+## @replaceable no
function big_console_header
{
true
}
+## @description disable function
+## @stability stable
+## @audience private
+## @replaceable no
function add_test
{
true
@@ -127,7 +142,7 @@ function yetus_usage
unset BUILDTOOLS
for plugin in ${BUGSYSTEMS}; do
- if declare -f ${plugin}_usage >/dev/null 2>&1; then
+ if declare -f "${plugin}_usage" >/dev/null 2>&1; then
echo ""
echo "${plugin} plugin usage options:"
"${plugin}_usage"
@@ -172,8 +187,7 @@ function parse_args
done
if [[ ! -d ${PATCH_DIR} ]]; then
- mkdir -p "${PATCH_DIR}"
- if [[ $? != 0 ]] ; then
+ if ! mkdir -p "${PATCH_DIR}"; then
yetus_error "ERROR: Unable to create ${PATCH_DIR}"
cleanup_and_exit 1
fi
@@ -213,7 +227,7 @@ function gitam_apply
yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-am.log" \
"${GIT}" am --signoff ${EXTRA_ARGS} --whitespace=fix "-p${PATCH_LEVEL}" "${patchfile}"
RESULT=$?
- ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-am.log"
+ "${GREP}" -v "^Checking" "${PATCH_DIR}/apply-patch-git-am.log"
# fallback
if [[ ${RESULT} -gt 0 && ${PATCH_SYSTEM} == 'jira' ]]; then
@@ -248,19 +262,19 @@ function gitapply_and_commit
jsontmpfile="${PATCH_DIR}/jsontmpfile"
# cannot set " as delimiter for cut command in script, so replace " with *
- tr ',' '\n' < "${PATCH_DIR}/issue" | ${SED} 's/\"/*/g' > "${jsontmpfile}"
+ tr ',' '\n' < "${PATCH_DIR}/issue" | "${SED}" 's/\"/*/g' > "${jsontmpfile}"
- assigneeline=$(${GREP} -n -E "^\*assignee\*:" "${jsontmpfile}" | cut -f1 -d":")
+ assigneeline=$("${GREP}" -n -E '^\*assignee\*:' "${jsontmpfile}" | cut -f1 -d":")
assigneefile="${PATCH_DIR}/assigneefile"
tail -n +"${assigneeline}" "${jsontmpfile}" | head -n 20 > "${assigneefile}"
- name=$(${GREP} "displayName" "${assigneefile}" | cut -f4 -d"*")
- email=$(${GREP} "emailAddress" "${assigneefile}" | cut -f4 -d"*" \
- | ${SED} 's/ at /@/g' | ${SED} 's/ dot /./g')
+ name=$("${GREP}" "displayName" "${assigneefile}" | cut -f4 -d"*")
+ email=$("${GREP}" "emailAddress" "${assigneefile}" | cut -f4 -d"*" \
+ | "${SED}" 's/ at /@/g' | "${SED}" 's/ dot /./g')
author="${name} <${email}>"
- summary=$(${GREP} -E "^\*summary\*:" "${jsontmpfile}" | cut -f4 -d"*")
+ summary=$("${GREP}" -E '^\*summary\*:' "${jsontmpfile}" | cut -f4 -d"*")
gitapply_apply "${patchfile}"
- ${GIT} add --all
+ "${GIT}" add --all
echo "Committing with author: ${author}, summary: ${summary}"
yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-am-fallback.log" \
"${GIT}" commit ${EXTRA_ARGS} --signoff -m "${PATCH_OR_ISSUE}. ${summary}" \
@@ -302,7 +316,7 @@ plugins_initialize
locate_patch
if [[ ${COMMITMODE} = true ]]; then
- status=$(${GIT} status --porcelain)
+ status=$("${GIT}" status --porcelain)
if [[ "$status" != "" ]] ; then
yetus_error "ERROR: Can't use --committer option in a workspace that contains the following modifications:"
yetus_error "${status}"
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/ant.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/ant.sh b/precommit/src/main/shell/test-patch.d/ant.sh
index 4c81741..9dd8240 100755
--- a/precommit/src/main/shell/test-patch.d/ant.sh
+++ b/precommit/src/main/shell/test-patch.d/ant.sh
@@ -46,7 +46,7 @@ function ant_parse_args
# if we requested offline, pass that to ant
if [[ ${OFFLINE} == "true" ]]; then
- ANT_ARGS=("${ANT_ARGS[@]}" -Doffline=)
+ ANT_ARGS=("${ANT_ARGS[@]}" '-Doffline=')
fi
}
@@ -144,8 +144,7 @@ function ant_javac_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016
- ${GREP} "\[javac\] /" "${input}" > "${output}"
+ "${GREP}" '\[javac\] /' "${input}" > "${output}"
}
## @description Helper for generic_logfilter
@@ -157,8 +156,7 @@ function ant_javadoc_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016
- ${GREP} "\[javadoc\] /" "${input}" > "${output}"
+ "${GREP}" '\[javadoc\] /' "${input}" > "${output}"
}
function ant_builtin_personality_modules
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/asflicense.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/asflicense.sh b/precommit/src/main/shell/test-patch.d/asflicense.sh
index 593e4af..0c22070 100755
--- a/precommit/src/main/shell/test-patch.d/asflicense.sh
+++ b/precommit/src/main/shell/test-patch.d/asflicense.sh
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
add_test_type asflicense
@@ -58,8 +59,9 @@ function asflicense_parse_args
## @return 1 on failure
function asflicense_tests
{
- local numpatch
- local btfails=true
+ declare numpatch
+ declare btfails=true
+ declare retval
big_console_header "Determining number of ASF License errors"
@@ -69,13 +71,16 @@ function asflicense_tests
case ${BUILDTOOL} in
ant)
modules_workers patch asflicense releaseaudit
+ retval=$?
;;
gradle)
btfails=false
modules_workers patch asflicense rat
+ retval=$?
;;
maven)
modules_workers patch asflicense -fn apache-rat:check
+ retval=$?
btfails=false
;;
*)
@@ -92,19 +97,21 @@ function asflicense_tests
-s "${PATCH_DIR}/asf.xsl" \
-E "${ASFLICENSE_RAT_EXCLUDES}" \
-d "${BASEDIR}"
+ retval=$?
else
echo_and_redirect "${PATCH_DIR}/patch-asflicense.txt" \
"${JAVA_HOME}/bin/java" \
-jar "${ASFLICENSE_RAT_JAR}" \
-s "${PATCH_DIR}/asf.xsl" \
"${BASEDIR}"
+ retval=$?
fi
;;
esac
# RAT fails the build if there are license problems.
# so let's take advantage of that a bit.
- if [[ $? == 0 && ${btfails} = true ]]; then
+ if [[ ${retval} == 0 && ${btfails} = true ]]; then
add_vote_table 1 asflicense "${BUILDMODEMSG} does not generate ASF License warnings."
return 0
fi
@@ -150,6 +157,12 @@ function asflicense_tests
return 0
}
+## @description when using the jar version, need an xsl file for it to use
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
function asflicense_writexsl
{
cat > "${1}" << EOF
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/autoconf.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/autoconf.sh b/precommit/src/main/shell/test-patch.d/autoconf.sh
index b1e2e2b..bf9476d 100755
--- a/precommit/src/main/shell/test-patch.d/autoconf.sh
+++ b/precommit/src/main/shell/test-patch.d/autoconf.sh
@@ -117,10 +117,10 @@ function autoconf_precompile
personality_modules "${repostatus}" autoreconf
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
echo_and_redirect "${PATCH_DIR}/${repostatus}-autoconf-autoreconf" autoreconf -fi
result=$?
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ ${result} != 0 ]]; then
if [[ "${repostatus}" = branch ]]; then
@@ -142,7 +142,7 @@ function autoconf_precompile
personality_modules "${repostatus}" configure
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
#shellcheck disable=SC2086
echo_and_redirect \
"${PATCH_DIR}/${repostatus}-autoconf-configure" \
@@ -150,7 +150,7 @@ function autoconf_precompile
--prefix="${PATCH_DIR}/${repostatus}-install-dir" \
${AUTOCONF_CONF_FLAGS}
result=$?
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ ${result} != 0 ]]; then
if [[ "${repostatus}" = branch ]]; then
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/bugzilla.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/bugzilla.sh b/precommit/src/main/shell/test-patch.d/bugzilla.sh
index 9b7caeb..d7f8f17 100755
--- a/precommit/src/main/shell/test-patch.d/bugzilla.sh
+++ b/precommit/src/main/shell/test-patch.d/bugzilla.sh
@@ -81,7 +81,7 @@ function bugzilla_http_fetch
return 1
fi
- ${CURL} --silent --fail \
+ "${CURL}" --silent --fail \
--output "${output}" \
--location \
"${BUGZILLA_BASE_URL}/${input}"
@@ -98,8 +98,7 @@ function bugzilla_locate_patch
return 1
fi
- bugzilla_determine_issue "${input}"
- if [[ $? != 0 || -z "${BUGZILLA_ISSUE}" ]]; then
+ if ! bugzilla_determine_issue "${input}" || [[ -z "${BUGZILLA_ISSUE}" ]]; then
return 1
fi
@@ -110,15 +109,13 @@ function bugzilla_locate_patch
return 1
fi
- bugzilla_http_fetch "show_bug.cgi?id=${BUGZILLA_ISSUE}" "${PATCH_DIR}/bugzilla"
-
- if [[ $? != 0 ]]; then
+ if ! bugzilla_http_fetch "show_bug.cgi?id=${BUGZILLA_ISSUE}" "${PATCH_DIR}/bugzilla"; then
yetus_debug "bugzilla_locate_patch: not a Bugzilla."
return 1
fi
#shellcheck disable=SC2016
- relativeurl=$(${AWK} '/action=diff/ && match($0,"attachment\.cgi.id=[0-9]*"){print substr($0,RSTART,RLENGTH)}' \
+ relativeurl=$("${AWK}" '/action=diff/ && match($0,"attachment\.cgi.id=[0-9]*"){print substr($0,RSTART,RLENGTH)}' \
"${PATCH_DIR}/bugzilla" | \
tail -1)
PATCHURL="${BUGZILLA_BASE_URL}${relativeurl}"
@@ -126,8 +123,7 @@ function bugzilla_locate_patch
echo "${input} patch is being downloaded at $(date) from"
echo "${PATCHURL}"
add_footer_table "Bugzilla Patch URL" "${PATCHURL}"
- bugzilla_http_fetch "${relativeurl}" "${fileloc}"
- if [[ $? != 0 ]];then
+ if ! bugzilla_http_fetch "${relativeurl}" "${fileloc}"; then
yetus_error "ERROR: ${input}/${PATCHURL} could not be downloaded."
cleanup_and_exit 1
fi
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/cc.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/cc.sh b/precommit/src/main/shell/test-patch.d/cc.sh
index 3241191..02bac8b 100755
--- a/precommit/src/main/shell/test-patch.d/cc.sh
+++ b/precommit/src/main/shell/test-patch.d/cc.sh
@@ -18,6 +18,12 @@ add_test_type cc
CC_EXT_RE='(c|cc|cpp|cxx|c\+\+|h|hh|hpp|hxx|h\+\+)'
+## @description discover files to check
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
function cc_filefilter
{
declare filename=$1
@@ -61,6 +67,6 @@ function cc_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} -i -E "^.*\.${CC_EXT_RE}\:[[:digit:]]*\:" "${input}" > "${output}"
+ #shellcheck disable=SC1117
+ "${GREP}" -i -E "^.*\.${CC_EXT_RE}\:[[:digit:]]*\:" "${input}" > "${output}"
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/checkstyle.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/checkstyle.sh b/precommit/src/main/shell/test-patch.d/checkstyle.sh
index 5bfca02..59f3b97 100755
--- a/precommit/src/main/shell/test-patch.d/checkstyle.sh
+++ b/precommit/src/main/shell/test-patch.d/checkstyle.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type checkstyle
CHECKSTYLE_TIMER=0
@@ -106,13 +108,13 @@ function checkstyle_calcdiffs
# so if only the error message numbers change
# we do not report new error
# shellcheck disable=SC2016
- cut -f3- -d: "${orig}" | awk -F'\1' '{ gsub("[0-9,]+", "", $2) ;print $1":"$2}' > "${tmp}.branch"
+ cut -f3- -d: "${orig}" | "${AWK}" -F'\1' '{ gsub("[0-9,]+", "", $2) ;print $1":"$2}' > "${tmp}.branch"
# shellcheck disable=SC2016
- cut -f3- -d: "${new}" | awk -F'\1' '{ gsub("[0-9,]+", "", $2) ;print $1":"$2}' > "${tmp}.patch"
+ cut -f3- -d: "${new}" | "${AWK}" -F'\1' '{ gsub("[0-9,]+", "", $2) ;print $1":"$2}' > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
- ${DIFF} --unchanged-line-format="" \
+ "${DIFF}" --unchanged-line-format="" \
--old-line-format="" \
--new-line-format="%dn " \
"${tmp}.branch" \
@@ -123,8 +125,7 @@ function checkstyle_calcdiffs
# message which was needed for calculations
# shellcheck disable=SC2013
for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${new}" | tail -1 | tr -d $'\x01'
+ head -"${j}" "${new}" | tail -1 | tr -d $'\x01'
done
rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
@@ -169,6 +170,8 @@ function checkstyle_runner
buildtool_cwd "${i}"
+ #BUG - fix this
+
case ${BUILDTOOL} in
ant)
cmd="${ANT} \
@@ -198,7 +201,7 @@ function checkstyle_runner
echo_and_redirect "${logfile}" ${cmd}
cmdresult=$?
- ${SED} -e 's,^\[ERROR\] ,,g' -e 's,^\[WARN\] ,,g' "${logfile}" \
+ "${SED}" -e 's,^\[ERROR\] ,,g' -e 's,^\[WARN\] ,,g' "${logfile}" \
| ${GREP} ^/ \
| ${SED} -e "s,${BASEDIR},.,g" \
> "${tmp}"
@@ -224,7 +227,7 @@ function checkstyle_runner
# have to do later
for j in "${CHANGED_FILES[@]}"; do
- ${GREP} "${j}" "${tmp}" >> "${tmp}.1"
+ "${GREP}" "${j}" "${tmp}" >> "${tmp}.1"
done
# now that we have just the files we care about,
@@ -246,7 +249,7 @@ function checkstyle_runner
# file:linenum:code(:column)\x01:error
# \x01 will later used to identify the begining
# of the checkstyle error message
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
while read -r logline; do
file=$(echo "${logline}" | cut -f1 -d:)
linenum=$(echo "${logline}" | cut -f2 -d:)
@@ -254,12 +257,12 @@ function checkstyle_runner
codeline=$(head -n "+${linenum}" "${file}" | tail -1 )
{
echo -n "${file}:${linenum}:${codeline}"
- echo -ne "\x01"
+ echo -ne '\x01'
echo ":${text}"
} >> "${output}"
done < <(cat "${tmp}.1")
- popd >/dev/null
+ popd >/dev/null || return 1
# later on, calcdiff will turn this into code(:column):error
# compare, and then put the file:line back onto it.
else
@@ -272,7 +275,7 @@ function checkstyle_runner
#shellcheck disable=SC2034
MODULE_STATUS_TIMER[${i}]=${savestop}
- popd >/dev/null
+ popd >/dev/null || return 1
((i=i+1))
done
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/cmake.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/cmake.sh b/precommit/src/main/shell/test-patch.d/cmake.sh
index 38a48c8..c3c72ab 100755
--- a/precommit/src/main/shell/test-patch.d/cmake.sh
+++ b/precommit/src/main/shell/test-patch.d/cmake.sh
@@ -78,7 +78,7 @@ function cmake_precheck
return 1
fi
# finally let folks know what version they'll be dealing with.
- cmake_version=$(${CMAKE} --version 2>/dev/null | head -n 1 2>/dev/null)
+ cmake_version=$("${CMAKE}" --version 2>/dev/null | head -n 1 2>/dev/null)
add_footer_table cmake "version: ${cmake_version}"
make_precheck
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/dupname.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/dupname.sh b/precommit/src/main/shell/test-patch.d/dupname.sh
index 6795308..fe77085 100755
--- a/precommit/src/main/shell/test-patch.d/dupname.sh
+++ b/precommit/src/main/shell/test-patch.d/dupname.sh
@@ -40,7 +40,7 @@ function dupname_icase_sort_array
oifs=${IFS}
fi
set -f
- # shellcheck disable=SC2034
+ # shellcheck disable=SC2034,SC2207
IFS=$'\n' sa=($(sort -f <<<"${array[*]}"))
# shellcheck disable=SC1083
eval "${arrname}"=\(\"\${sa[@]}\"\)
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/findbugs.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/findbugs.sh b/precommit/src/main/shell/test-patch.d/findbugs.sh
index 84a807b..e21cfbd 100755
--- a/precommit/src/main/shell/test-patch.d/findbugs.sh
+++ b/precommit/src/main/shell/test-patch.d/findbugs.sh
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
FINDBUGS_HOME=${FINDBUGS_HOME:-}
FINDBUGS_WARNINGS_FAIL_PRECHECK=false
@@ -30,7 +31,7 @@ function findbugs_usage
function findbugs_parse_args
{
- local i
+ declare i
for i in "$@"; do
case ${i} in
@@ -60,7 +61,7 @@ function findbugs_initialize
function findbugs_filefilter
{
- local filename=$1
+ declare filename=$1
if [[ ${BUILDTOOL} == maven
|| ${BUILDTOOL} == ant ]]; then
@@ -141,13 +142,15 @@ function findbugs_maven_skipper
## @param repostatus
function findbugs_runner
{
- local name=$1
- local module
- local result=0
- local fn
- local warnings_file
- local i=0
- local savestop
+ declare name=$1
+ declare module
+ declare result=0
+ declare fn
+ declare warnings_file
+ declare i=0
+ declare savestop
+ declare retval
+
personality_modules "${name}" findbugs
@@ -197,11 +200,14 @@ function findbugs_runner
if [[ ${name} == branch ]]; then
"${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name "${PATCH_BRANCH}" \
"${warnings_file}.xml" "${warnings_file}.xml"
+ retval=$?
else
"${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name patch \
"${warnings_file}.xml" "${warnings_file}.xml"
+ retval=$?
fi
- if [[ $? != 0 ]]; then
+
+ if [[ ${retval} != 0 ]]; then
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
module_status ${i} -1 "" "${name}/${module} cannot run setBugDatabaseInfo from findbugs"
@@ -210,10 +216,9 @@ function findbugs_runner
continue
fi
- "${FINDBUGS_HOME}/bin/convertXmlToText" -html \
+ if ! "${FINDBUGS_HOME}/bin/convertXmlToText" -html \
"${warnings_file}.xml" \
- "${warnings_file}.html"
- if [[ $? != 0 ]]; then
+ "${warnings_file}.html"; then
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
module_status ${i} -1 "" "${name}/${module} cannot run convertXmlToText from findbugs"
@@ -387,17 +392,16 @@ function findbugs_postinstall
newbugsbase="${PATCH_DIR}/new-findbugs-${fn}"
fixedbugsbase="${PATCH_DIR}/fixed-findbugs-${fn}"
- "${FINDBUGS_HOME}/bin/computeBugHistory" -useAnalysisTimes -withMessages \
+ if ! "${FINDBUGS_HOME}/bin/computeBugHistory" -useAnalysisTimes -withMessages \
-output "${combined_xml}" \
"${branchxml}" \
- "${patchxml}"
- if [[ $? != 0 ]]; then
- popd >/dev/null
+ "${patchxml}"; then
module_status ${i} -1 "" "${module} cannot run computeBugHistory from findbugs"
((result=result+1))
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
((i=i+1))
+ popd >/dev/null || return 1
continue
fi
@@ -411,40 +415,41 @@ function findbugs_postinstall
#shellcheck disable=SC2016
add_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first patch \
"${combined_xml}" "${newbugsbase}.xml" | ${AWK} '{print $1}')
- if [[ $? != 0 ]]; then
- popd >/dev/null
+ retval=$?
+ if [[ ${retval} != 0 ]]; then
module_status ${i} -1 "" "${module} cannot run filterBugs (#1) from findbugs"
((result=result+1))
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
((i=i+1))
+ popd >/dev/null || return 1
continue
fi
#shellcheck disable=SC2016
fixed_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -fixed patch \
"${combined_xml}" "${fixedbugsbase}.xml" | ${AWK} '{print $1}')
- if [[ $? != 0 ]]; then
- popd >/dev/null
+ retval=$?
+ if [[ ${retval} != 0 ]]; then
module_status ${i} -1 "" "${module} cannot run filterBugs (#2) from findbugs"
((result=result+1))
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
((i=i+1))
+ popd >/dev/null || return 1
continue
fi
statstring=$(generic_calcdiff_status "${branch_warnings}" "${patch_warnings}" "${add_warnings}")
- "${FINDBUGS_HOME}/bin/convertXmlToText" -html "${newbugsbase}.xml" \
- "${newbugsbase}.html"
- if [[ $? != 0 ]]; then
- popd >/dev/null
+ if ! "${FINDBUGS_HOME}/bin/convertXmlToText" -html "${newbugsbase}.xml" \
+ "${newbugsbase}.html"; then
module_status ${i} -1 "" "${module} cannot run convertXmlToText from findbugs"
((result=result+1))
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
((i=i+1))
+ popd >/dev/null || return 1
continue
fi
@@ -465,7 +470,7 @@ function findbugs_postinstall
fi
savestop=$(stop_clock)
MODULE_STATUS_TIMER[${i}]=${savestop}
- popd >/dev/null
+ popd >/dev/null || return 1
((i=i+1))
done
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/github.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/github.sh b/precommit/src/main/shell/test-patch.d/github.sh
index ce6fa2f..17df408 100755
--- a/precommit/src/main/shell/test-patch.d/github.sh
+++ b/precommit/src/main/shell/test-patch.d/github.sh
@@ -103,7 +103,7 @@ function github_jira_bridge
declare urlfromjira
# shellcheck disable=SC2016
- urlfromjira=$(${AWK} "match(\$0,\"${GITHUB_BASE_URL}/[^ ]*patch[ &\\\"]\"){url=substr(\$0,RSTART,RLENGTH-1)}
+ urlfromjira=$("${AWK}" "match(\$0,\"${GITHUB_BASE_URL}/[^ ]*patch[ &\\\"]\"){url=substr(\$0,RSTART,RLENGTH-1)}
END{if (url) print url}" "${jsonloc}" )
if [[ -z $urlfromjira ]]; then
# This is currently the expected path, as github pull requests are not common
@@ -204,8 +204,7 @@ function github_determine_issue
# if JIRA didn't call us, should we call it?
if [[ ${GITHUB_BRIDGED} == false ]]; then
- github_find_jira_title
- if [[ $? == 0 ]]; then
+ if github_find_jira_title; then
return 0
fi
fi
@@ -230,7 +229,7 @@ function github_determine_branch
fi
# shellcheck disable=SC2016
- PATCH_BRANCH=$(${AWK} 'match($0,"\"ref\": \""){print $2}' "${PATCH_DIR}/github-pull.json"\
+ PATCH_BRANCH=$("${AWK}" 'match($0,"\"ref\": \""){print $2}' "${PATCH_DIR}/github-pull.json"\
| cut -f2 -d\"\
| tail -1 )
@@ -436,7 +435,7 @@ function github_linecomments
fi
if [[ -z "${GITHUB_COMMITSHA}" ]]; then
- GITHUB_COMMITSHA=$(${GREP} \"sha\" "${PATCH_DIR}/github-pull.json" 2>/dev/null \
+ GITHUB_COMMITSHA=$("${GREP}" \"sha\" "${PATCH_DIR}/github-pull.json" 2>/dev/null \
| head -1 \
| cut -f4 -d\")
fi
@@ -449,7 +448,7 @@ function github_linecomments
{
printf "{\"body\":\""
echo "${plugin}: ${text}" \
- | ${SED} -e 's,\\,\\\\,g' \
+ | "${SED}" -e 's,\\,\\\\,g' \
-e 's,\",\\\",g' \
-e 's,$,\\r\\n,g' \
| tr -d '\n'
@@ -498,7 +497,7 @@ function github_write_comment
{
printf "{\"body\":\""
- ${SED} -e 's,\\,\\\\,g' \
+ "${SED}" -e 's,\\,\\\\,g' \
-e 's,\",\\\",g' \
-e 's,$,\\r\\n,g' "${commentfile}" \
| tr -d '\n'
@@ -555,17 +554,16 @@ function github_finalreport
else
echo ":broken_heart: **-1 overall**" >> "${commentfile}"
fi
-
- printf "\n\n\n\n" >> "${commentfile}"
+ printf '\n\n\n\n' >> "${commentfile}"
i=0
until [[ ${i} -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
+ printf '%s\n\n' "${TP_HEADER[${i}]}" >> "${commentfile}"
((i=i+1))
done
{
- printf "\n\n"
+ printf '\n\n'
echo "| Vote | Subsystem | Runtime | Comment |"
echo "|:----:|----------:|--------:|:--------|"
} >> "${commentfile}"
@@ -586,7 +584,7 @@ function github_finalreport
if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
{
- printf "\n\n"
+ printf '\n\n'
echo "| Reason | Tests |"
echo "|-------:|:------|"
} >> "${commentfile}"
@@ -598,7 +596,7 @@ function github_finalreport
fi
{
- printf "\n\n"
+ printf '\n\n'
echo "| Subsystem | Report/Notes |"
echo "|----------:|:-------------|"
} >> "${commentfile}"
@@ -607,11 +605,10 @@ function github_finalreport
until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
${SED} -e "s,@@BASE@@,${BUILD_URL}${BUILD_URL_ARTIFACTS},g")
- printf "%s\n" "${comment}" >> "${commentfile}"
+ printf '%s\n' "${comment}" >> "${commentfile}"
((i=i+1))
done
-
- printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
+ printf '\n\nThis message was automatically generated.\n\n' >> "${commentfile}"
github_write_comment "${commentfile}"
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/gradle.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/gradle.sh b/precommit/src/main/shell/test-patch.d/gradle.sh
index 8c78ab4..6c580ba 100755
--- a/precommit/src/main/shell/test-patch.d/gradle.sh
+++ b/precommit/src/main/shell/test-patch.d/gradle.sh
@@ -59,7 +59,7 @@ function gradle_precheck
return 1
fi
# finally let folks know what version they'll be dealing with.
- gradle_version=$(${GRADLE} --version 2>/dev/null | grep Gradle 2>/dev/null)
+ gradle_version=$("${GRADLE}" --version 2>/dev/null | grep Gradle 2>/dev/null)
add_footer_table gradle "version: ${gradle_version}"
return 0
}
@@ -129,9 +129,9 @@ function gradle_precompile
personality_modules "${repostatus}" gradleboot
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
echo_and_redirect "${PATCH_DIR}/${repostatus}-gradle-bootstrap.txt" gradle -b bootstrap.gradle
- popd >/dev/null
+ popd >/dev/null || return 1
modules_workers "${repostatus}" gradleboot
result=$?
@@ -151,8 +151,7 @@ function gradle_javac_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} "\.java" "${input}" > "${output}"
+ "${GREP}" '\.java' "${input}" > "${output}"
}
## @description Helper for generic_logfilter
@@ -164,8 +163,7 @@ function gradle_javadoc_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} "javadoc.*\.java" "${input}" > "${output}"
+ "${GREP}" 'javadoc.*\.java' "${input}" > "${output}"
}
## @description Helper for generic_logfilter
@@ -177,8 +175,7 @@ function gradle_scaladoc_logfilter
declare input=$1
declare output=$2
- #shellcheck disable=SC2016,SC2046
- ${GREP} "^\[ant:scaladoc\] /.*\.scala" "${input}" > "${output}"
+ "${GREP}" '^\[ant:scaladoc\] /.*\.scala' "${input}" > "${output}"
}
function gradle_modules_worker
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/hadolint.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/hadolint.sh b/precommit/src/main/shell/test-patch.d/hadolint.sh
index 804bd4a..b5e068b 100755
--- a/precommit/src/main/shell/test-patch.d/hadolint.sh
+++ b/precommit/src/main/shell/test-patch.d/hadolint.sh
@@ -80,7 +80,6 @@ function hadolint_logic
for i in "${HADOLINT_CHECKFILES[@]}"; do
if [[ -f "${i}" ]]; then
- echo " * ${i}"
"${HADOLINT}" "${i}" >> "${PATCH_DIR}/${repostatus}-hadolint-result.txt"
fi
done
@@ -114,12 +113,12 @@ function hadolint_calcdiffs
# first, pull out just the errors
# shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${branch}" | cut -d' ' -f2- > "${tmp}.branch"
+ "${AWK}" -F: '{print $NF}' "${branch}" | cut -d' ' -f2- > "${tmp}.branch"
# shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${patch}" | cut -d' ' -f2- > "${tmp}.patch"
+ "${AWK}" -F: '{print $NF}' "${patch}" | cut -d' ' -f2- > "${tmp}.patch"
- ${DIFF} --unchanged-line-format="" \
+ "${DIFF}" --unchanged-line-format="" \
--old-line-format="" \
--new-line-format="%dn " \
"${tmp}.branch" \
@@ -128,8 +127,7 @@ function hadolint_calcdiffs
# now, pull out those lines of the raw output
# shellcheck disable=SC2013
for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${patch}" | tail -1
+ head -"${j}" "${patch}" | tail -1
done
rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
@@ -165,13 +163,13 @@ function hadolint_postapply
> "${PATCH_DIR}/diff-patch-hadolint.txt"
# shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-hadolint-result.txt" | ${AWK} '{print $1}')
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-hadolint-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-hadolint-result.txt" | ${AWK} '{print $1}')
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-hadolint-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-hadolint.txt" | ${AWK} '{print $1}')
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-hadolint.txt" | "${AWK}" '{print $1}')
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/htmlout.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/htmlout.sh b/precommit/src/main/shell/test-patch.d/htmlout.sh
index 9439412..ef44cb0 100755
--- a/precommit/src/main/shell/test-patch.d/htmlout.sh
+++ b/precommit/src/main/shell/test-patch.d/htmlout.sh
@@ -107,7 +107,7 @@ function htmlout_finalreport
until [[ $i -eq ${#TP_HEADER[@]} ]]; do
ourstring=$(echo "${TP_HEADER[${i}]}" | tr -s ' ')
comment=$(echo "${ourstring}" | cut -f2 -d\|)
- printf "<tr><td>%s</td></tr>\n" "${comment}"
+ printf '<tr><td>%s</td></tr>\n' "${comment}"
((i=i+1))
done
@@ -133,10 +133,10 @@ function htmlout_finalreport
if [[ "${vote}" = "H" ]]; then
{
echo "<tr>"
- printf "\t\t<td></td>"
+ printf '\t\t<td></td>'
printf "<td></td>"
printf "<td></td>"
- printf "<td><font color=\"%s\">%s</font></td>\n" "brown" "${comment}"
+ printf '<td><font color=\"%s\">%s</font></td>\n' "brown" "${comment}"
echo "</tr>"
} >> "${commentfile}"
((i=i+1))
@@ -173,10 +173,10 @@ function htmlout_finalreport
{
echo "<tr>"
- printf "\t\t<td><font color=\"%s\">%s</font></td>" "${color}" "${vote}"
+ printf '\t\t<td><font color=\"%s\">%s</font></td>' "${color}" "${vote}"
printf "<td><font color=\"%s\">%s</font></td>" "${color}" "${subs}"
printf "<td><font color=\"%s\">%s</font></td>" "${color}" "${calctime}"
- printf "<td><font color=\"%s\">%s</font></td>\n" "${color}" "${comment}"
+ printf '<td><font color=\"%s\">%s</font></td>\n' "${color}" "${comment}"
echo "</tr>"
} >> "${commentfile}"
((i=i+1))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/java.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/java.sh b/precommit/src/main/shell/test-patch.d/java.sh
index 8515650..2482189 100755
--- a/precommit/src/main/shell/test-patch.d/java.sh
+++ b/precommit/src/main/shell/test-patch.d/java.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type javac
add_test_type javadoc
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/jira.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/jira.sh b/precommit/src/main/shell/test-patch.d/jira.sh
index c01587e..00c7a54 100755
--- a/precommit/src/main/shell/test-patch.d/jira.sh
+++ b/precommit/src/main/shell/test-patch.d/jira.sh
@@ -91,7 +91,7 @@ function jira_determine_issue
fi
# shellcheck disable=SC2016
- patchnamechunk=$(echo "${input}" | ${AWK} -F/ '{print $NF}')
+ patchnamechunk=$(echo "${input}" | "${AWK}" -F/ '{print $NF}')
maybeissue=$(echo "${patchnamechunk}" | cut -f1,2 -d-)
@@ -115,13 +115,13 @@ function jira_http_fetch
yetus_debug "jira_http_fetch: ${JIRA_URL}/${input}"
if [[ -n "${JIRA_USER}"
&& -n "${JIRA_PASSWD}" ]]; then
- ${CURL} --silent --fail \
+ "${CURL}" --silent --fail \
--user "${JIRA_USER}:${JIRA_PASSWD}" \
--output "${output}" \
--location \
"${JIRA_URL}/${input}"
else
- ${CURL} --silent --fail \
+ "${CURL}" --silent --fail \
--output "${output}" \
--location \
"${JIRA_URL}/${input}"
@@ -165,8 +165,7 @@ function jira_locate_patch
return 1
fi
- jira_http_fetch "browse/${input}" "${PATCH_DIR}/jira"
- if [[ $? != 0 ]]; then
+ if ! jira_http_fetch "browse/${input}" "${PATCH_DIR}/jira"; then
yetus_debug "jira_locate_patch: not a JIRA."
return 1
fi
@@ -180,8 +179,7 @@ function jira_locate_patch
jira_http_fetch "rest/api/2/issue/${input}" "${jsonloc}"
# Parse the downloaded information to check if the issue is
# just a pointer to GitHub.
- github_jira_bridge "${fileloc}" "${jsonloc}"
- if [[ $? -eq 0 ]]; then
+ if github_jira_bridge "${fileloc}" "${jsonloc}"; then
echo "${input} appears to be a Github PR. Switching Modes."
return 0
fi
@@ -189,7 +187,7 @@ function jira_locate_patch
fi
# Not reached if there is a successful github plugin return
- if [[ $(${GREP} -c "${JIRA_STATUS_RE}" "${PATCH_DIR}/jira") == 0 ]]; then
+ if [[ $("${GREP}" -c "${JIRA_STATUS_RE}" "${PATCH_DIR}/jira") == 0 ]]; then
if [[ ${ROBOT} == true ]]; then
yetus_error "ERROR: ${input} issue status is not matched with \"${JIRA_STATUS_RE}\"."
cleanup_and_exit 1
@@ -204,9 +202,9 @@ function jira_locate_patch
# ascending order. so bigger # == newer file
#shellcheck disable=SC2016
tr '>' '\n' < "${PATCH_DIR}/jira" \
- | ${AWK} 'match($0,"/secure/attachment/[0-9]*/[^\"]*"){print substr($0,RSTART,RLENGTH)}' \
- | ${GREP} -v -e 'htm[l]*$' \
- | ${SED} -e 's,[ ]*$,,g' \
+ | "${AWK}" 'match($0,"/secure/attachment/[0-9]*/[^\"]*"){print substr($0,RSTART,RLENGTH)}' \
+ | "${GREP}" -v -e 'htm[l]*$' \
+ | "${SED}" -e 's,[ ]*$,,g' \
| sort -n -r -k4 -t/ \
| uniq \
> "${PATCH_DIR}/jira-attachments.txt"
@@ -237,8 +235,7 @@ function jira_locate_patch
fi
if [[ ! ${PATCHURL} =~ \.patch$ ]]; then
- guess_patch_file "${fileloc}"
- if [[ $? == 0 ]]; then
+ if guess_patch_file "${fileloc}"; then
yetus_debug "The patch ${PATCHURL} was not named properly, but it looks like a patch file. Proceeding, but issue/branch matching might go awry."
add_vote_table 0 patch "The patch file was not named according to ${PROJECT_NAME}'s naming conventions. Please see ${PATCH_NAMING_RULE} for instructions."
else
@@ -280,7 +277,7 @@ function jira_determine_branch
yetus_debug "Determine branch: starting with ${hinttype}"
patchnamechunk=$(echo "${hinttype}" \
- | ${SED} -e 's,.*/\(.*\)$,\1,' \
+ | "${SED}" -e 's,.*/\(.*\)$,\1,' \
-e 's,\.txt,.,' \
-e 's,.patch,.,g' \
-e 's,.diff,.,g' \
@@ -369,14 +366,14 @@ function jira_write_comment
# RESTify the comment
{
echo "{\"body\":\""
- ${SED} -e 's,\\,\\\\,g' \
+ "${SED}" -e 's,\\,\\\\,g' \
-e 's,\",\\\",g' \
-e 's,$,\\r\\n,g' "${commentfile}" \
| tr -d '\n'
echo "\"}"
} > "${PATCH_DIR}/jiracomment.$$"
- ${CURL} -X POST \
+ "${CURL}" -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-u "${JIRA_USER}:${JIRA_PASSWD}" \
@@ -434,7 +431,7 @@ function jira_finalreport
i=0
until [[ $i -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
+ printf '%s\n' "${TP_HEADER[${i}]}" >> "${commentfile}"
((i=i+1))
done
@@ -488,8 +485,7 @@ function jira_finalreport
;;
esac
fi
-
- printf "| {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} |\n" \
+ printf '| {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} |\n' \
"${color}" "${vote}" \
"${color}" "${subs}" \
"${color}" "${calctime}" \
@@ -504,7 +500,7 @@ function jira_finalreport
echo "|| Reason || Tests ||" >> "${commentfile}"
i=0
until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
- printf "%s\n" "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
+ printf '%s\n' "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
((i=i+1))
done
fi
@@ -515,12 +511,12 @@ function jira_finalreport
i=0
until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
- ${SED} -e "s,@@BASE@@,${BUILD_URL}${BUILD_URL_ARTIFACTS},g")
- printf "%s\n" "${comment}" >> "${commentfile}"
+ "${SED}" -e "s,@@BASE@@,${BUILD_URL}${BUILD_URL_ARTIFACTS},g")
+ printf '%s\n' "${comment}" >> "${commentfile}"
((i=i+1))
done
- printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
+ printf '\n\nThis message was automatically generated.\n\n' >> "${commentfile}"
jira_write_comment "${commentfile}"
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/junit.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/junit.sh b/precommit/src/main/shell/test-patch.d/junit.sh
index 0bbe23e..fe9c2a3 100755
--- a/precommit/src/main/shell/test-patch.d/junit.sh
+++ b/precommit/src/main/shell/test-patch.d/junit.sh
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_format junit
JUNIT_TEST_TIMEOUTS=""
@@ -54,7 +56,7 @@ function junit_process_tests
declare module_failed_tests
# shellcheck disable=SC2016
- module_test_timeouts=$(${AWK} '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${buildlogfile}")
+ module_test_timeouts=$("${AWK}" '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${buildlogfile}")
if [[ -n "${module_test_timeouts}" ]] ; then
JUNIT_TEST_TIMEOUTS="${JUNIT_TEST_TIMEOUTS} ${module_test_timeouts}"
((result=result+1))
@@ -63,7 +65,7 @@ function junit_process_tests
#shellcheck disable=SC2026,SC2038,SC2016
module_failed_tests=$(find "${JUNIT_TEST_OUTPUT_DIR}" -name 'TEST*.xml'\
| xargs "${GREP}" -l -E "<failure|<error"\
- | ${AWK} -F/ '{sub("'"TEST-${JUNIT_TEST_PREFIX}"'",""); sub(".xml",""); print $NF}')
+ | "${AWK}" -F/ '{sub("'"TEST-${JUNIT_TEST_PREFIX}"'",""); sub(".xml",""); print $NF}')
if [[ -n "${module_failed_tests}" ]] ; then
JUNIT_FAILED_TESTS="${JUNIT_FAILED_TESTS} ${module_failed_tests}"
((result=result+1))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/make.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/make.sh b/precommit/src/main/shell/test-patch.d/make.sh
index 6fb2b59..76ab6af 100755
--- a/precommit/src/main/shell/test-patch.d/make.sh
+++ b/precommit/src/main/shell/test-patch.d/make.sh
@@ -16,7 +16,7 @@
add_build_tool make
-MAKE=make
+MAKE=$(command -v make 2>/dev/null)
MAKEFILE=Makefile
## @description make usage hook
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/maven.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/maven.sh b/precommit/src/main/shell/test-patch.d/maven.sh
index 13e2867..7741254 100755
--- a/precommit/src/main/shell/test-patch.d/maven.sh
+++ b/precommit/src/main/shell/test-patch.d/maven.sh
@@ -69,6 +69,9 @@ function maven_ws_replace
fi
}
+## @description maven usage message
+## @audience private
+## @stability evolving
function maven_usage
{
maven_ws_replace
@@ -216,8 +219,7 @@ function maven_precheck
if [[ ! -d "${MAVEN_LOCAL_REPO}" ]]; then
yetus_debug "Creating ${MAVEN_LOCAL_REPO}"
- mkdir -p "${MAVEN_LOCAL_REPO}"
- if [[ $? -ne 0 ]]; then
+ if ! mkdir -p "${MAVEN_LOCAL_REPO}"; then
yetus_error "ERROR: Unable to create ${MAVEN_LOCAL_REPO}"
return 1
fi
@@ -251,6 +253,9 @@ function maven_precheck
add_footer_table maven "version: ${maven_version}"
}
+## @description maven trigger
+## @audience private
+## @stability evolving
function maven_filefilter
{
declare filename=$1
@@ -261,16 +266,25 @@ function maven_filefilter
fi
}
+## @description maven build file
+## @audience private
+## @stability evolving
function maven_buildfile
{
echo "pom.xml"
}
+## @description execute maven
+## @audience private
+## @stability evolving
function maven_executor
{
echo "${MAVEN}" "${MAVEN_ARGS[@]}"
}
+## @description mvn site trigger
+## @audience private
+## @stability evolving
function mvnsite_filefilter
{
local filename=$1
@@ -331,6 +345,9 @@ function maven_modules_worker
esac
}
+## @description process javac output from maven
+## @audience private
+## @stability evolving
function maven_javac_logfilter
{
declare input=$1
@@ -365,17 +382,14 @@ function maven_javac_calcdiffs
declare orig=$1
declare new=$2
declare tmp=${PATCH_DIR}/pl.$$.${RANDOM}
- declare j
# first, strip :[line
# this keeps file,column in an attempt to increase
# accuracy in case of multiple, repeated errors
# since the column number shouldn't change
# if the line of code hasn't been touched
- # shellcheck disable=SC2016
- ${SED} -e 's#:\[[0-9]*,#:#' "${orig}" > "${tmp}.branch"
- # shellcheck disable=SC2016
- ${SED} -e 's#:\[[0-9]*,#:#' "${new}" > "${tmp}.patch"
+ "${SED}" -e 's#:\[[0-9]*,#:#' "${orig}" > "${tmp}.branch"
+ "${SED}" -e 's#:\[[0-9]*,#:#' "${new}" > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
@@ -388,8 +402,7 @@ function maven_javac_calcdiffs
# now, pull out those lines of the raw output
# shellcheck disable=SC2013
for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${new}" | tail -1
+ head -"${j}" "${new}" | tail -1
done
rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
@@ -407,15 +420,12 @@ function maven_javadoc_calcdiffs
declare orig=$1
declare new=$2
declare tmp=${PATCH_DIR}/pl.$$.${RANDOM}
- declare j
# can't use the generic handler for this because of the
# [WARNING], etc headers.
# strip :linenum from the output, keeping the filename
- # shellcheck disable=SC2016
- ${SED} -e 's#:[0-9]*:#:#' "${orig}" > "${tmp}.branch"
- # shellcheck disable=SC2016
- ${SED} -e 's#:[0-9]*:#:#' "${new}" > "${tmp}.patch"
+ "${SED}" -e 's#:[0-9]*:#:#' "${orig}" > "${tmp}.branch"
+ "${SED}" -e 's#:[0-9]*:#:#' "${new}" > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
@@ -428,18 +438,21 @@ function maven_javadoc_calcdiffs
# now, pull out those lines of the raw output
# shellcheck disable=SC2013
for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${new}" | tail -1
+ head -"${j}" "${new}" | tail -1
done
rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
}
+
+## @description maven personality handler
+## @audience private
+## @stability evolving
+## @replaceable yes
function maven_builtin_personality_modules
{
declare repostatus=$1
declare testtype=$2
-
declare module
yetus_debug "Using builtin personality_modules"
@@ -461,6 +474,10 @@ function maven_builtin_personality_modules
done
}
+## @description maven default test triggers
+## @audience private
+## @stability evolving
+## @replaceable yes
function maven_builtin_personality_file_tests
{
local filename=$1
@@ -621,6 +638,10 @@ function maven_precompile
return 0
}
+## @description set volumes as appropriate for maven
+## @audience private
+## @stability evolving
+## @replaceable yes
function maven_docker_support
{
DOCKER_EXTRAARGS=("${DOCKER_EXTRAARGS[@]}" "-v" "${HOME}/.m2:/home/${USER_NAME}/.m2")
@@ -657,7 +678,7 @@ function maven_reorder_module_process
done
fn=$(module_file_fragment "${CHANGED_UNION_MODULES}")
- pushd "${BASEDIR}/${CHANGED_UNION_MODULES}" >/dev/null
+ pushd "${BASEDIR}/${CHANGED_UNION_MODULES}" >/dev/null || return 1
# get the module directory list in the correct order based on maven dependencies
# shellcheck disable=SC2046
@@ -675,7 +696,7 @@ function maven_reorder_module_process
fi
done
done < "${PATCH_DIR}/maven-${repostatus}-dirlist-${fn}.txt"
- popd >/dev/null
+ popd >/dev/null || return 1
if [[ "${needroot}" = true ]]; then
newlist=("${newlist[@]}" ".")
@@ -764,5 +785,6 @@ function maven_reorder_modules
fi
fi
+ # shellcheck disable=SC2046
echo "Elapsed: $(clock_display $(stop_clock))"
}
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/nobuild.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/nobuild.sh b/precommit/src/main/shell/test-patch.d/nobuild.sh
index cf5a2ad..a049f98 100755
--- a/precommit/src/main/shell/test-patch.d/nobuild.sh
+++ b/precommit/src/main/shell/test-patch.d/nobuild.sh
@@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
+# A simple build system that doesn't actually build anything
+
add_build_tool nobuild
function nobuild_buildfile
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/perlcritic.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/perlcritic.sh b/precommit/src/main/shell/test-patch.d/perlcritic.sh
index 291e94e..f2ee183 100755
--- a/precommit/src/main/shell/test-patch.d/perlcritic.sh
+++ b/precommit/src/main/shell/test-patch.d/perlcritic.sh
@@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type perlcritic
PERLCRITIC_TIMER=0
-PERLCRITIC=${PERLCRITIC:-$(which perlcritic 2>/dev/null)}
+PERLCRITIC=${PERLCRITIC:-$(command -v perlcritic 2>/dev/null)}
function perlcritic_usage
{
@@ -69,13 +71,13 @@ function perlcritic_preapply
start_clock
echo "Running perlcritic against identified perl scripts/modules."
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/branch-perlcritic-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
# keep track of how much as elapsed for us already
PERLCRITIC_TIMER=$(stop_clock)
return 0
@@ -116,13 +118,13 @@ function perlcritic_postapply
echo "Running perlcritic against identified perl scripts/modules."
# we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/patch-perlcritic-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
PERLCRITIC_VERSION=$(${PERLCRITIC} --version 2>/dev/null)
add_footer_table perlcritic "v${PERLCRITIC_VERSION}"
@@ -134,13 +136,13 @@ function perlcritic_postapply
> "${PATCH_DIR}/diff-patch-perlcritic.txt"
# shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | ${AWK} '{print $1}')
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | ${AWK} '{print $1}')
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | "${AWK}" '{print $1}')
# shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | ${AWK} '{print $1}')
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | "${AWK}" '{print $1}')
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/rubocop.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/rubocop.sh b/precommit/src/main/shell/test-patch.d/rubocop.sh
index 828bea1..490c985 100755
--- a/precommit/src/main/shell/test-patch.d/rubocop.sh
+++ b/precommit/src/main/shell/test-patch.d/rubocop.sh
@@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type rubocop
RUBOCOP_TIMER=0
-RUBOCOP=${RUBOCOP:-$(which rubocop 2>/dev/null)}
+RUBOCOP=${RUBOCOP:-$(command -v rubocop 2>/dev/null)}
function rubocop_usage
{
@@ -69,13 +71,13 @@ function rubocop_preapply
start_clock
echo "Running rubocop against identified ruby scripts."
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/branch-rubocop-result.txt"
+ "${RUBOCOP}" -f e "${i}" | "${AWK}" '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/branch-rubocop-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
# keep track of how much as elapsed for us already
RUBOCOP_TIMER=$(stop_clock)
return 0
@@ -116,16 +118,16 @@ function rubocop_postapply
echo "Running rubocop against identified ruby scripts."
# we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/patch-rubocop-result.txt"
+ "${RUBOCOP}" -f e "${i}" | "${AWK}" '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/patch-rubocop-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
# shellcheck disable=SC2016
- RUBOCOP_VERSION=$(${RUBOCOP} -v | ${AWK} '{print $NF}')
+ RUBOCOP_VERSION=$("${RUBOCOP}" -v | "${AWK}" '{print $NF}')
add_footer_table rubocop "v${RUBOCOP_VERSION}"
calcdiffs \
@@ -133,13 +135,13 @@ function rubocop_postapply
"${PATCH_DIR}/patch-rubocop-result.txt" \
rubocop \
> "${PATCH_DIR}/diff-patch-rubocop.txt"
- diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-rubocop.txt")
+ diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-rubocop.txt")
# shellcheck disable=SC2016
- numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-rubocop-result.txt")
+ numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-rubocop-result.txt")
# shellcheck disable=SC2016
- numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-rubocop-result.txt")
+ numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-rubocop-result.txt")
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
http://git-wip-us.apache.org/repos/asf/yetus/blob/9a2cd581/precommit/src/main/shell/test-patch.d/ruby-lint.sh
----------------------------------------------------------------------
diff --git a/precommit/src/main/shell/test-patch.d/ruby-lint.sh b/precommit/src/main/shell/test-patch.d/ruby-lint.sh
index 78be7b6..50c2d7b 100755
--- a/precommit/src/main/shell/test-patch.d/ruby-lint.sh
+++ b/precommit/src/main/shell/test-patch.d/ruby-lint.sh
@@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# SHELLDOC-IGNORE
+
add_test_type ruby_lint
RUBY_LINT_TIMER=0
-RUBY_LINT=${RUBY_LINT:-$(which ruby-lint 2>/dev/null)}
+RUBY_LINT=${RUBY_LINT:-$(command -v ruby-lint 2>/dev/null)}
function ruby_lint_usage
{
@@ -68,13 +70,13 @@ function ruby_lint_preapply
start_clock
echo "Running ruby-lint against identified ruby scripts."
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
+ "${RUBY_LINT}" -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
# keep track of how much as elapsed for us already
RUBY_LINT_TIMER=$(stop_clock)
return 0
@@ -100,14 +102,12 @@ function ruby_lint_calcdiffs
# accuracy in case of multiple, repeated errors
# since the column number shouldn't change
# if the line of code hasn't been touched
- # shellcheck disable=SC2016
cut -f4- -d: "${orig}" > "${tmp}.branch"
- # shellcheck disable=SC2016
cut -f4- -d: "${new}" > "${tmp}.patch"
# compare the errors, generating a string of line
# numbers. Sorry portability: GNU diff makes this too easy
- ${DIFF} --unchanged-line-format="" \
+ "${DIFF}" --unchanged-line-format="" \
--old-line-format="" \
--new-line-format="%dn " \
"${tmp}.branch" \
@@ -116,8 +116,7 @@ function ruby_lint_calcdiffs
# now, pull out those lines of the raw output
# shellcheck disable=SC2013
for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${new}" | tail -1
+ head -"${j}" "${new}" | tail -1
done
rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
@@ -146,16 +145,16 @@ function ruby_lint_postapply
echo "Running ruby-lint against identified ruby scripts."
# we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
+ pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
+ "${RUBY_LINT}" -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
fi
done
- popd >/dev/null
+ popd >/dev/null || return 1
# shellcheck disable=SC2016
- RUBY_LINT_VERSION=$(${RUBY_LINT} -v | ${AWK} '{print $2}')
+ RUBY_LINT_VERSION=$("${RUBY_LINT}" -v | "${AWK}" '{print $2}')
add_footer_table ruby-lint "${RUBY_LINT_VERSION}"
calcdiffs \
@@ -163,13 +162,13 @@ function ruby_lint_postapply
"${PATCH_DIR}/patch-ruby-lint-result.txt" \
ruby_lint \
> "${PATCH_DIR}/diff-patch-ruby-lint.txt"
- diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.txt")
+ diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.txt")
# shellcheck disable=SC2016
- numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-ruby-lint-result.txt")
+ numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-ruby-lint-result.txt")
# shellcheck disable=SC2016
- numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
+ numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))