Skip to content

Commit

Permalink
lint optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 22, 2024
1 parent 5b5e4f5 commit 96c32b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions steps/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,21 @@ if ! bibcop --version >/dev/null 2>&1; then
fi
bibcop tex/report.bib

find "${LOCAL}" -name '*.sh' -type f -print0 | xargs -0 -n1 shellcheck --shell=bash --severity=style
while IFS= read -r sh; do
shellcheck --shell=bash --severity=style "${sh}"
done < <(find "$(realpath "${LOCAL}")" -name '*.sh' -type f -not -path "$(realpath "${TARGET}")/**")

header="Copyright (c) 2021-$(date +%Y) Yegor Bugayenko"
copyright_check="false"
while IFS= read -r file; do
if ! grep -q "$header" "$file"; then
copyright_check="true"
echo "⚠️ Copyright not found in file: $file"
fi
done < <(find "$LOCAL" \( -path "$LOCAL/fixtures/filters/unparseable" -prune \) -o \( -path "$LOCAL/test-zone" -prune \) -o -type f \( -name "*.sh" -o -name "*.py" -o -name "*.rb" -o -name "*.java" -o -name "*.xml" -o -name "Makefile" \) -print)
if [[ "${copyright_check}" = "true" ]]; then
exit 1
fi
failed="false"
for mask in *.sh *.py *.rb *.java Makefile; do
while IFS= read -r file; do
if ! grep -q "$header" "$file"; then
failed="true"
echo "⚠️ Copyright not found in file: $file"
fi
done < <(find "$(realpath "${LOCAL}")" -type f -name "${mask}" \
-not -path "$(realpath "${TARGET}")/**" \
-not -path "$(realpath "${LOCAL}")/fixtures/filters/unparseable/**" \
-not -path "$(realpath "${LOCAL}")/test-zone/**")
done
if [[ "${failed}" = "true" ]]; then exit; fi
2 changes: 1 addition & 1 deletion steps/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export CAMTESTS=1
dir="${LOCAL}/tests"
tests=$(
find "${dir}" -mindepth 2 -type f -name '*.sh' -path "${dir}/before/**";
find "${dir}" -mindepth 2 -type f -name '*.sh' -not -path "${dir}/before/**" -not -path "${dir}/after/**" | sort;
find "${dir}" -mindepth 2 -type f -name '*.sh' -not -path "${dir}/before/**" -not -path "${dir}/after/**" | sort;
find "${dir}" -mindepth 2 -type f -name '*.sh' -path "${dir}/after/**"
)
echo "There are $(echo "${tests}" | wc -l | xargs) tests in ${dir}"
Expand Down

0 comments on commit 96c32b2

Please sign in to comment.