Skip to content

Commit c76768c

Browse files
authored
dataconnect: shellcheck (lint) bash shell scripts (#7215)
1 parent a00e2be commit c76768c

12 files changed

+74
-17
lines changed

.github/workflows/dataconnect.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,17 @@ jobs:
271271
with:
272272
args: -color /github/workspace/.github/workflows/dataconnect.yml
273273

274+
shellcheck:
275+
continue-on-error: false
276+
runs-on: ubuntu-latest
277+
steps:
278+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
279+
with:
280+
show-progress: false
281+
sparse-checkout: 'firebase-dataconnect/'
282+
- name: shellcheck
283+
run: find . -name '*.sh' -print0 | xargs --verbose -0 shellcheck --norc --enable=all --shell=bash
284+
274285
python-ci-unit-tests:
275286
continue-on-error: false
276287
runs-on: ubuntu-latest

firebase-dataconnect/emulator/emulator.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly SCRIPT_DIR="$(dirname "$0")"
19+
SCRIPT_DIR="$(dirname "$0")"
20+
readonly SCRIPT_DIR
2021
readonly SELF_EXECUTABLE="$0"
2122
readonly LOG_PREFIX="[$0] "
2223
readonly DEFAULT_POSTGRESQL_STRING='postgresql://postgres:postgres@localhost:5432?sslmode=disable'
@@ -38,7 +39,7 @@ function parse_args {
3839
local OPTIND=1
3940
local OPTERR=0
4041
while getopts ":c:p:v:hwg" arg ; do
41-
case "$arg" in
42+
case "${arg}" in
4243
c) emulator_binary="${OPTARG}" ;;
4344
g) emulator_binary="gradle" ;;
4445
p) postgresql_string="${OPTARG}" ;;
@@ -59,21 +60,21 @@ function parse_args {
5960
exit 2
6061
;;
6162
*)
62-
log_error_and_exit "INTERNAL ERROR: unknown argument: $arg"
63+
log_error_and_exit "INTERNAL ERROR: unknown argument: ${arg}"
6364
;;
6465
esac
6566
done
6667

67-
if [[ $emulator_binary != "gradle" ]] ; then
68+
if [[ ${emulator_binary} != "gradle" ]] ; then
6869
export DATACONNECT_EMULATOR_BINARY_PATH="${emulator_binary}"
6970
else
7071
run_command "${SCRIPT_DIR}/../../gradlew" -p "${SCRIPT_DIR}/../.." --configure-on-demand :firebase-dataconnect:connectors:downloadDebugDataConnectExecutable
7172
local gradle_emulator_binaries=("${SCRIPT_DIR}"/../connectors/build/intermediates/dataconnect/debug/executable/*)
7273
if [[ ${#gradle_emulator_binaries[@]} -ne 1 ]]; then
7374
log_error_and_exit "expected exactly 1 emulator binary from gradle, but got ${#gradle_emulator_binaries[@]}: ${gradle_emulator_binaries[*]}"
7475
fi
75-
local gradle_emulator_binary="${gradle_emulator_binaries[@]}"
76-
if [[ ! -e $gradle_emulator_binary ]] ; then
76+
local gradle_emulator_binary="${gradle_emulator_binaries[0]}"
77+
if [[ ! -e ${gradle_emulator_binary} ]] ; then
7778
log_error_and_exit "emulator binary from gradle does not exist: ${gradle_emulator_binary}"
7879
fi
7980
export DATACONNECT_EMULATOR_BINARY_PATH="${gradle_emulator_binary}"
@@ -82,7 +83,7 @@ function parse_args {
8283
export FIREBASE_DATACONNECT_POSTGRESQL_STRING="${postgresql_string}"
8384
export DATA_CONNECT_PREVIEW="${preview_flags}"
8485

85-
if [[ $wipe_and_restart_postgres_pod == "1" ]] ; then
86+
if [[ ${wipe_and_restart_postgres_pod} == "1" ]] ; then
8687
run_command "${SCRIPT_DIR}/wipe_postgres_db.sh"
8788
run_command "${SCRIPT_DIR}/start_postgres_pod.sh"
8889
fi

firebase-dataconnect/emulator/start_postgres_pod.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ function run_command {
2525
"$@"
2626
}
2727

28-
# Determine the absolute path of the directory containing this file.
29-
readonly SCRIPT_DIR="$(readlink -f $(dirname "$0"))"
28+
# Determine the path of the directory containing this file.
29+
SCRIPT_DIR="$(dirname "$0")"
30+
readonly SCRIPT_DIR
3031

3132
# Create the podman "pod" if it is not already created.
3233
# Bind the PostgreSQL server to port 5432 on the host, so that the host can connect to it.

firebase-dataconnect/scripts/compile_kotlin.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly TARGETS=(
2223
":firebase-dataconnect:compileDebugKotlin"

firebase-dataconnect/scripts/emulator_run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
(
2223
set -xv

firebase-dataconnect/scripts/generateApiTxtFile.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly args=(
2223
"${PROJECT_ROOT_DIR}/gradlew"

firebase-dataconnect/scripts/generate_data_connect_sources.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly TARGETS=(
2223
":firebase-dataconnect:connectors:generateDebugDataConnectSources"

firebase-dataconnect/scripts/run_all_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly TARGETS=(
2223
":firebase-dataconnect:androidTestutil:connectedDebugAndroidTest"

firebase-dataconnect/scripts/run_integration_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly TARGETS=(
2223
":firebase-dataconnect:connectedDebugAndroidTest"

firebase-dataconnect/scripts/run_unit_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
set -euo pipefail
1818

19-
readonly PROJECT_ROOT_DIR="$(dirname "$0")/../.."
19+
PROJECT_ROOT_DIR="$(dirname "$0")/../.."
20+
readonly PROJECT_ROOT_DIR
2021

2122
readonly TARGETS=(
2223
":firebase-dataconnect:testDebugUnitTest"

0 commit comments

Comments
 (0)