From b4f31d0fa5508151048bad7d91e7133f5f7d894a Mon Sep 17 00:00:00 2001 From: Ryan Beck-Buysse Date: Thu, 10 Oct 2019 15:40:53 -0500 Subject: [PATCH] Simplify run_lint script Signed-off-by: Ryan Beck-Buysse --- bin/run_lint | 78 +++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/bin/run_lint b/bin/run_lint index b0155fe2bd..7d0bed6166 100755 --- a/bin/run_lint +++ b/bin/run_lint @@ -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