Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Simplify run_lint script
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Beck-Buysse <[email protected]>
  • Loading branch information
rbuysse committed Oct 10, 2019
1 parent 3bbd0d6 commit b4f31d0
Showing 1 changed file with 32 additions and 46 deletions.
78 changes: 32 additions & 46 deletions bin/run_lint
Original file line number Diff line number Diff line change
Expand Up @@ -16,61 +16,47 @@

top_dir=$(cd $(dirname $(dirname $0)) && pwd)

dirs="
$top_dir/sdk
$top_dir/cli
$top_dir/contracts/schema
$top_dir/contracts/pike
$top_dir/contracts/product
$top_dir/contracts/track_and_trace
$top_dir/daemon
"

exitcode=0

for dir in $dirs; do
cd $dir
echo "$dir"

echo "-- rustfmt"
cd $top_dir

diff=$(cargo fmt -- --check)
rustfmt_exit=$?
echo "-- rustfmt"

# cargo fmt -- --check returns the following exit codes:
#
# 0 = No errors
# 1 = Formatted code differs from existing code (check only)
diff=$(cargo fmt -- --check)
rustfmt_exit=$?

if [[ $rustfmt_exit != 0 ]]; then
exitcode=1
if [[ $rustfmt_exit == 1 ]]; then
echo "Incorrect formatting: $dir (error code: $rustfmt_exit)"
echo "$diff"
else
echo "rustfmt encountered an operational error"
fi
# cargo fmt -- --check returns the following exit codes:
#
# 0 = No errors
# 1 = Formatted code differs from existing code (check only)

if [[ $rustfmt_exit != 0 ]]; then
exitcode=1
if [[ $rustfmt_exit == 1 ]]; then
echo "Incorrect formatting: (error code: $rustfmt_exit)"
echo "$diff"
else
echo "rustfmt encountered an operational error"
fi
fi

echo "-- Clippy"
echo "-- Clippy"

cargo clippy -- -D warnings
clippy_exit=$?
cargo clippy -- -D warnings
clippy_exit=$?

# cargo clippy -- -D warnings returns the following exit codes:
#
# 0 = No errors or warnings
# 101 = rustc or clippy has found errors or warnings in the code

if [[ $clippy_exit != 0 ]]; then
exitcode=1
if [[ $clippy_exit == 101 ]]; then
echo "Clippy errors were found: $dir (error code: $clippy_exit)"
else
echo "Clippy encountered an operational error"
fi
# cargo clippy -- -D warnings returns the following exit codes:
#
# 0 = No errors or warnings
# 101 = rustc or clippy has found errors or warnings in the code

if [[ $clippy_exit != 0 ]]; then
exitcode=1
if [[ $clippy_exit == 101 ]]; then
echo "Clippy errors were found: (error code: $clippy_exit)"
else
echo "Clippy encountered an operational error"
fi

done
fi

exit $exitcode

0 comments on commit b4f31d0

Please sign in to comment.