mirror of
https://github.com/vale981/ray
synced 2025-03-06 18:41:40 -05:00

* Fix SC2001: See if you can use ${variable//search/replace} instead. * Fix SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames. * Fix SC2012: Use find instead of ls to better handle non-alphanumeric filenames. * Fix SC2015: Note that A && B || C is not if-then-else. C may run when A is true. * Fix SC2028: echo may not expand escape sequences. Use printf. * Fix SC2034: variable appears unused. Verify use (or export if used externally). * Fix SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options. * Fix SC2071: > is for string comparisons. Use -gt instead. * Fix SC2154: variable is referenced but not assigned * Fix SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. * Fix SC2188: This redirection doesn't have a command. Move to its command (or use 'true' as no-op). * Fix SC2236: Use -n instead of ! -z. * Fix SC2242: Can only exit with status 0-255. Other data should be written to stdout/stderr. * Fix SC2086: Double quote to prevent globbing and word splitting. Co-authored-by: Mehrdad <noreply@github.com>
50 lines
1.1 KiB
Bash
Executable file
50 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Before running this script, please make sure golang is installed
|
|
# and buildifier is also installed. The example is showed in .travis.yml.
|
|
set -e
|
|
|
|
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
|
|
|
|
function usage()
|
|
{
|
|
echo "Usage: bazel-format.sh [<args>]"
|
|
echo
|
|
echo "Options:"
|
|
echo " -h|--help print the help info"
|
|
echo " -c|--check check whether there are format issues in bazel files"
|
|
echo " -f|--fix fix all the format issue directly"
|
|
echo
|
|
}
|
|
|
|
RUN_TYPE="diff"
|
|
|
|
# Parse options
|
|
while [ $# -gt 0 ]; do
|
|
key="$1"
|
|
case $key in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
-c|--check)
|
|
RUN_TYPE="diff"
|
|
;;
|
|
-f|--fix)
|
|
RUN_TYPE=fix
|
|
;;
|
|
*)
|
|
echo "ERROR: unknown option \"$key\""
|
|
echo
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
pushd "$ROOT_DIR"/../..
|
|
BAZEL_FILES=(bazel/BUILD bazel/BUILD.arrow bazel/ray.bzl BUILD.bazel java/BUILD.bazel \
|
|
cpp/BUILD.bazel streaming/BUILD.bazel streaming/java/BUILD.bazel WORKSPACE)
|
|
buildifier -mode=$RUN_TYPE -diff_command="diff -u" "${BAZEL_FILES[@]}"
|
|
popd
|