-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use common script for linting, rather than spread commands... Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
- Loading branch information
1 parent
b7dd0fb
commit 8a2c311
Showing
3 changed files
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env sh | ||
|
||
cargo fmt --version | ||
cargo fmt --all | ||
set -e | ||
|
||
cargo clippy --version | ||
cargo clippy --all --all-targets $1 -- -D warnings | ||
FMT_ERROR= | ||
|
||
OP="${1:-}" | ||
|
||
case "$OP" in | ||
"" | "fmt" | "clippy") | ||
;; | ||
*) | ||
echo "linter $OP not supported" | ||
exit 2 | ||
esac | ||
|
||
cargo fmt -- --version | ||
cargo clippy -- --version | ||
|
||
if [ -z "$OP" ] || [ "$OP" = "fmt" ]; then | ||
cargo fmt --all --check || FMT_ERROR=$? | ||
if [ -n "$FMT_ERROR" ]; then | ||
cargo fmt --all | ||
fi | ||
fi | ||
|
||
if [ -z "$OP" ] || [ "$OP" = "clippy" ]; then | ||
cargo clippy --all --all-targets -- -D warnings | ||
fi | ||
|
||
exit ${FMT_ERROR:-0} |