Skip to content

Commit

Permalink
fix(bash files): E001, E011
Browse files Browse the repository at this point in the history
  • Loading branch information
markparonyan committed Feb 16, 2025
1 parent 4a7f6ed commit e4620b2
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 13 deletions.
8 changes: 6 additions & 2 deletions filters/001-move-gits-to-temp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ set -o pipefail

temp=$2

if [ ! -e "${TARGET}/github" ]; then exit; fi
if [ ! -e "${TARGET}/github" ]; then
exit;
fi

list=${temp}/git-to-move.txt
find "${TARGET}/github" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'realpath --relative-to="${1}" "$2"' _ "${TARGET}/github" {} \; > "${list}"
Expand All @@ -37,7 +39,9 @@ mkdir -p "${gits}"
if [ -s "${list}" ]; then
while IFS= read -r repo; do
src=${TARGET}/github/${repo}/.git
if [ ! -e "${src}" ]; then continue; fi
if [ ! -e "${src}" ]; then
continue;
fi
mkdir -p "$(dirname "${gits}/${repo}")"
mv "${src}" "${gits}/${repo}"
done < "${list}"
Expand Down
4 changes: 3 additions & 1 deletion filters/050-delete-long-lines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ candidates=${temp}/files-to-check-line-lengths.txt
find "${home}" -type f -name '*.java' -print > "${candidates}"
while IFS= read -r f; do
length=$(LC_ALL=C awk '{ print length($0) }' < "${f}" | sort -n | tail -1)
if [ -z "${length}" ]; then continue; fi
if [ -z "${length}" ]; then
continue;
fi
if [ "${length}" -gt "${max}" ]; then
echo "${f}" >> "${list}"
rm "${f}"
Expand Down
4 changes: 3 additions & 1 deletion filters/080-delete-symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ touch "${list}"
while true; do
slice=${temp}/symlinks-to-delete.txt
find "${home}" -mindepth 1 -type l -print > "${slice}"
if [ ! -s "${slice}" ]; then break; fi
if [ ! -s "${slice}" ];then
break;
fi
while IFS= read -r link; do
rm "${link}"
echo "${link}" >> "${list}"
Expand Down
4 changes: 3 additions & 1 deletion filters/090-delete-empty-directories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ touch "${list}"
while true; do
slice=${temp}/empty-directories-to-delete.txt
find "${home}" -mindepth 1 -type d -empty -print > "${slice}"
if [ ! -s "${slice}" ]; then break; fi
if [ ! -s "${slice}" ]; then
break
fi
while IFS= read -r dir; do
rm -r "${dir}"
echo "${dir}" >> "${list}"
Expand Down
8 changes: 6 additions & 2 deletions filters/999-move-gits-back.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ set -o pipefail

temp=$2

if [ ! -e "${temp}/gits" ]; then exit; fi
if [ ! -e "${temp}/gits" ]; then
exit;
fi

repos=${temp}/git-repos-moving-back.txt

Expand All @@ -35,7 +37,9 @@ find "${temp}/gits" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'realpath --re
if [ -s "${repos}" ]; then
while IFS= read -r repo; do
dest=${TARGET}/github/${repo}
if [ ! -e "${dest}" ]; then continue; fi
if [ ! -e "${dest}" ]; then
continue;
fi
mv "${temp}/gits/${repo}" "${dest}/.git"
done < "${repos}"
fi
4 changes: 3 additions & 1 deletion help/parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ set -o pipefail

jobs=$1
x=$2
if [ -z "${x}" ]; then x=1; fi
if [ -z "${x}" ]; then
x=1;
fi

cores=$(echo "$(nproc) * ${x}" | bc)
args=(
Expand Down
8 changes: 6 additions & 2 deletions steps/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ declare -i repo=0
sh="$(dirname "$0")/clone-repo.sh"
while IFS=',' read -r r tag tail; do
repo=$((repo+1))
if [ -z "${tag}" ]; then tag='master'; fi
if [ "${tag}" = '.' ]; then tag='master'; fi
if [ -z "${tag}" ]; then
tag='master';
fi
if [ "${tag}" = '.' ]; then
tag='master';
fi
if [ -e "${TARGET}/github/${r}" ]; then
echo "${r}: Git repo is already here (${tail})"
else
Expand Down
4 changes: 3 additions & 1 deletion steps/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ for mask in *.sh *.py *.rb *.yml *.java Makefile; do
-not -path "$(realpath "${LOCAL}")/test-zone/**" \
-not -path "$(realpath "${LOCAL}")/venv/**")
done
if [[ "${failed}" = "true" ]]; then exit; fi
if [[ "${failed}" = "true" ]]; then
exit;
fi
4 changes: 3 additions & 1 deletion steps/report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ for idx in "${!groups[@]}"; do
else
group_metrics=$(grep -oE ".*\b${groups[$idx]}\b.*" "${list}" || :)
fi
if [[ $(printf "%s\n" "${group_metrics[@]}" | grep -c "item") -eq 0 ]]; then continue; fi
if [[ $(printf "%s\n" "${group_metrics[@]}" | grep -c "item") -eq 0 ]]; then
continue;
fi
printf "\\item %s\n" "${groups[$idx]}" >> "${st_list}"
printf "\\\\begin{itemize}\n" >> "${st_list}"
while IFS= read -r metric; do
Expand Down
4 changes: 3 additions & 1 deletion steps/unregister.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ echo "${head}" > "${csv}"
declare -i total=0
declare -i good=0
while IFS=',' read -r r tag tail; do
if [ -z "${r}" ]; then continue; fi
if [ -z "${r}" ]; then
continue;
fi
total=$((total+1))
if [ ! -e "${TARGET}/github/${r}" ]; then
echo "The clone of ${r} is absent, unregistered"
Expand Down

0 comments on commit e4620b2

Please sign in to comment.