-
Notifications
You must be signed in to change notification settings - Fork 38
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 <[email protected]>
- Loading branch information
1 parent
24fd03a
commit c9ed89c
Showing
3 changed files
with
31 additions
and
8 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 -- --config imports_granularity=Crate | ||
set -e | ||
|
||
FMT_ERROR= | ||
|
||
OP="${1:-}" | ||
|
||
case "$OP" in | ||
"" | "fmt" | "clippy") | ||
;; | ||
*) | ||
echo "linter $OP not supported" | ||
exit 2 | ||
esac | ||
|
||
cargo fmt -- --version | ||
cargo clippy -- --version | ||
cargo clippy --all --all-targets $1 -- -D warnings | ||
|
||
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} |