Skip to content

Commit 74d21d4

Browse files
authored
chore: Enable shellcheck in prek (pre-commit) (#155)
### Summary Enables shellcheck linter in prek and fixes current issues. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - None. - Bug Fixes - Improved reliability of shell scripts by quoting variables to prevent word splitting and globbing. - Documentation build now correctly forwards user-supplied arguments and handles paths with spaces. - Superset initialisation scripts handle special characters and spaces in credentials and database names. - Chores - Added a ShellCheck pre-commit hook to automatically lint shell scripts and prevent common errors. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 2047b64 commit 74d21d4

4 files changed

Lines changed: 15 additions & 19 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ repos:
1616
# Run the formatter.
1717
- id: ruff-format
1818
files: elt-common
19+
- repo: https://github.com/koalaman/shellcheck-precommit
20+
rev: v0.11.0
21+
hooks:
22+
- id: shellcheck

docs/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ DEFAULT_BUILD_ARGS="--clean"
2222
build_dir=$1
2323
shift 1
2424
project_root=$SCRIPT_DIR
25-
user_build_args=$*
25+
user_build_args=("$@")
2626

2727
# Create and configure environment
28-
pushd $project_root
28+
pushd "$project_root"
2929
uv venv $VENV_DIR
3030
uv pip install -r requirements.txt
3131

3232
# Build
33-
uv run mkdocs build $DEFAULT_BUILD_ARGS --site-dir $build_dir
33+
uv run mkdocs build $DEFAULT_BUILD_ARGS "${user_build_args[@]}" --site-dir "$build_dir"
3434
popd

infra/ansible-docker/roles/superset/templates/docker/docker-init.sh.j2

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,17 @@ echo_step "1" "Starting" "Applying DB migrations"
4343
superset db upgrade
4444
echo_step "1" "Complete" "Applying DB migrations"
4545

46-
# Create an admin user
47-
{# echo_step "2" "Starting" "Setting up admin user admin "
48-
superset fab create-admin \
49-
--username $SUPERSET_ADMIN_USER \
50-
--firstname $SUPERSET_ADMIN_FIRSTNAME \
51-
--lastname $SUPERSET_ADMIN_LASTNAME \
52-
--email $SUPERSET_ADMIN_EMAIL \
53-
--password $SUPERSET_ADMIN_PASSWORD
54-
echo_step "2" "Complete" "Setting up admin user" #}
55-
5646
# Create default roles and permissions
5747
echo_step "2" "Starting" "Setting up roles and perms"
5848
superset init
5949
echo_step "2" "Complete" "Setting up roles and perms"
6050

6151
# Create a database connection(s)
6252
echo_step "3" "Starting" "Setting up Iceberg catalog connection(s)"
53+
# shellcheck disable=1000-9999
6354
{% for analytic_db in superset_analytic_dbs %}
6455
superset set-database-uri \
6556
--database_name {{ analytic_db.database_name }} --uri "{{ analytic_db.uri }}"
57+
# shellcheck disable=1000-9999
6658
{% endfor %}
6759
echo_step "3" "Complete" "Setting up data source database connection(s)"

infra/local/superset/docker/docker-init.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ echo_step "1" "Complete" "Applying DB migrations"
4646
# Create an admin user
4747
echo_step "2" "Starting" "Setting up admin user admin "
4848
superset fab create-admin \
49-
--username $SUPERSET_ADMIN_USER \
50-
--firstname $SUPERSET_ADMIN_FIRSTNAME \
51-
--lastname $SUPERSET_ADMIN_LASTNAME \
52-
--email $SUPERSET_ADMIN_EMAIL \
53-
--password $SUPERSET_ADMIN_PASSWORD
49+
--username "$SUPERSET_ADMIN_USER" \
50+
--firstname "$SUPERSET_ADMIN_FIRSTNAME" \
51+
--lastname "$SUPERSET_ADMIN_LASTNAME" \
52+
--email "$SUPERSET_ADMIN_EMAIL" \
53+
--password "$SUPERSET_ADMIN_PASSWORD"
5454
echo_step "2" "Complete" "Setting up admin user"
5555

5656
# Create default roles and permissions
@@ -61,6 +61,6 @@ echo_step "3" "Complete" "Setting up roles and perms"
6161
# Create a database connection
6262
echo_step "4" "Starting" "Setting up Iceberg catalog connection"
6363
superset set-database-uri \
64-
--database_name $SUPERSET_DB_SCHEMA_NAME \
64+
--database_name "$SUPERSET_DB_SCHEMA_NAME" \
6565
--uri "trino://trino@trino:8080/$SUPERSET_DB_SCHEMA_NAME"
6666
echo_step "4" "Complete" "Setting up data source database connection"

0 commit comments

Comments
 (0)