mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 02:27:58 +01:00
[fix-a-javadoc] Modernize, tell xargs to run in parallel
This commit is contained in:
parent
b0729d83a8
commit
602aafe119
1 changed files with 34 additions and 18 deletions
|
@ -17,11 +17,6 @@ popd > /dev/null
|
||||||
|
|
||||||
SMACK_DIR=$(realpath "${SCRIPTDIR}"/..)
|
SMACK_DIR=$(realpath "${SCRIPTDIR}"/..)
|
||||||
|
|
||||||
FIND_ALL_JAVA_SRC="find ${SMACK_DIR} \
|
|
||||||
-type f \
|
|
||||||
-name *.java \
|
|
||||||
-print"
|
|
||||||
|
|
||||||
declare -A SMACK_EXCEPTIONS
|
declare -A SMACK_EXCEPTIONS
|
||||||
SMACK_EXCEPTIONS[NotConnectedException]="if the XMPP connection is not connected."
|
SMACK_EXCEPTIONS[NotConnectedException]="if the XMPP connection is not connected."
|
||||||
SMACK_EXCEPTIONS[InterruptedException]="if the calling thread was interrupted."
|
SMACK_EXCEPTIONS[InterruptedException]="if the calling thread was interrupted."
|
||||||
|
@ -71,7 +66,8 @@ SMACK_EXCEPTIONS[FailedNonzaException]="if an XMPP protocol failure was received
|
||||||
|
|
||||||
MODE=""
|
MODE=""
|
||||||
|
|
||||||
while getopts dm: OPTION "$@"; do
|
SMACK_DIR=$(realpath "${SCRIPTDIR}"/..)
|
||||||
|
while getopts dm:p: OPTION "$@"; do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
d)
|
d)
|
||||||
set -x
|
set -x
|
||||||
|
@ -79,6 +75,9 @@ while getopts dm: OPTION "$@"; do
|
||||||
m)
|
m)
|
||||||
MODE=${OPTARG}
|
MODE=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
SMACK_DIR=${OPTARG}
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option ${OPTION}"
|
echo "Unknown option ${OPTION}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -86,26 +85,43 @@ while getopts dm: OPTION "$@"; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
JAVA_SOURCES_LIST=$(mktemp)
|
||||||
|
onExit() {
|
||||||
|
rm "${JAVA_SOURCES_LIST}"
|
||||||
|
}
|
||||||
|
trap onExit EXIT
|
||||||
|
|
||||||
|
find ${SMACK_DIR} \
|
||||||
|
-type f \
|
||||||
|
-name "*.java" \
|
||||||
|
-print > "${JAVA_SOURCES_LIST}"
|
||||||
|
|
||||||
|
NPROC=$(nproc)
|
||||||
|
|
||||||
sed_sources() {
|
sed_sources() {
|
||||||
sedScript=${1}
|
sedScript=${1}
|
||||||
${FIND_ALL_JAVA_SRC} |\
|
|
||||||
xargs sed \
|
xargs \
|
||||||
|
--max-procs="${NPROC}" \
|
||||||
|
--max-args=8 \
|
||||||
|
-- \
|
||||||
|
sed \
|
||||||
--in-place \
|
--in-place \
|
||||||
--follow-symlinks \
|
--follow-symlinks \
|
||||||
--regexp-extended \
|
--regexp-extended \
|
||||||
"${sedScript}"
|
"${sedScript}" < "${JAVA_SOURCES_LIST}"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_affected() {
|
show_affected() {
|
||||||
echo ${!SMACK_EXCEPTIONS{@}}
|
echo ${!SMACK_EXCEPTIONS{@}}
|
||||||
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
||||||
${FIND_ALL_JAVA_SRC} |\
|
xargs grep " \* @throws $exception$" < "${JAVA_SOURCES_LIST}"
|
||||||
xargs grep " \* @throws $exception$" || true
|
|
||||||
done
|
done
|
||||||
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
||||||
count=$(${FIND_ALL_JAVA_SRC} |\
|
local count
|
||||||
xargs grep " \* @throws $exception$" | wc -l)
|
count=$(<"${JAVA_SOURCES_LIST}" xargs grep " \* @throws $exception$" |\
|
||||||
echo "$exception $count"
|
wc -l)
|
||||||
|
echo "$exception $count"q
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,7 +129,7 @@ show_affected() {
|
||||||
fix_affected() {
|
fix_affected() {
|
||||||
for exception in "${!SMACK_EXCEPTIONS[@]}"; do
|
for exception in "${!SMACK_EXCEPTIONS[@]}"; do
|
||||||
exceptionJavadoc=${SMACK_EXCEPTIONS[${exception}]}
|
exceptionJavadoc=${SMACK_EXCEPTIONS[${exception}]}
|
||||||
sed_sources "s;@throws ((\w*\.)?${exception})\$;@throws \1 ${exceptionJavadoc};"
|
sed_sources "s;@throws ((\w*\.)?${exception}) ?\$;@throws \1 ${exceptionJavadoc};"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue