Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add spellcheck to pre-commit config (#718)

MustkimKhatik28bfd1696fb3
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2e121d6ae..d4e707dc9 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -55,3 +55,7 @@ repos:
- id: black
args:
- --safe
+ - repo: https://github.com/koalaman/shellcheck-precommit
+ rev: v0.8.0
+ hooks:
+ - id: shellcheck
diff --git a/dag-sync.sh b/dag-sync.sh
index e52e3293a..0cbd38504 100755
--- a/dag-sync.sh
+++ b/dag-sync.sh
@@ -14,16 +14,14 @@ SLACK_URL=$1
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"
-# Get current commit hash
-current=$(git rev-parse HEAD)
# Update origin
git fetch origin
# Get new commit hash *one commit ahead* of this one
new=$(git rev-list --reverse --topo-order HEAD..origin/main | head -1)
# If there is no new commit hash to move to, nothing has changed, quit early
-[ -z $new ] && exit
+[ -z "$new" ] && exit
# Move ahead to this new commit
-git reset --hard $new
+git reset --hard "$new"
# Pull out the subject from the new commit
subject=$(git log -1 --format='%s')
@@ -32,7 +30,7 @@ if [ -z "$SLACK_URL" ]
then
echo "Slack hook was not supplied! Updates will not be posted"
else
- curl $SLACK_URL \
+ curl "$SLACK_URL" \
-X POST \
-H 'Content-Type: application/json' \
-d '{"text":"Deployed: '"$subject"'","username":"DAG Sync","icon_emoji":":recycle:","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"Deployed: <https://github.com/WordPress/openverse-catalog/commit/'"$new"'|'"$subject"'>"}}]}'
diff --git a/docker/airflow/entrypoint.sh b/docker/airflow/entrypoint.sh
index 0bf41f3ec..742134beb 100755
--- a/docker/airflow/entrypoint.sh
+++ b/docker/airflow/entrypoint.sh
@@ -41,20 +41,20 @@ header "MODIFYING ENVIRONMENT"
# subprocess manipulation via <(...) syntax to allow the `export` calls
# to propagate to the outer shell.
# See: https://unix.stackexchange.com/a/402752
-while read var_string; do
+while read -r var_string; do
# get the variable name
- var_name=`expr "$var_string" : '^\([A-Z_]*\)'`
+ var_name=$(expr "$var_string" : '^\([A-Z_]*\)')
echo "Variable Name: $var_name"
# get the old value
- old_value=`expr "$var_string" : '^[A-Z_]*=\(http.*\)$'`
+ old_value=$(expr "$var_string" : '^[A-Z_]*=\(http.*\)$')
echo " Old Value: $old_value"
# call python to url encode the http clause
- url_encoded=`python -c "from urllib.parse import quote_plus; import sys; print(quote_plus(sys.argv[1]))" $old_value`
+ url_encoded=$(python -c "from urllib.parse import quote_plus; import sys; print(quote_plus(sys.argv[1]))" "$old_value")
# prepend https://
new_value='https://'$url_encoded
echo " New Value: $new_value"
# set the environment variable
- export $var_name=$new_value
+ export "$var_name"="$new_value"
# only include airflow connections with http somewhere in the string
done < <(env | grep "^AIRFLOW_CONN[A-Z_]\+=http.*$")
diff --git a/tests/dags/providers/provider_api_scripts/resources/wikimedia/prettify.sh b/tests/dags/providers/provider_api_scripts/resources/wikimedia/prettify.sh
index 14c8f46e1..a96d755a9 100755
--- a/tests/dags/providers/provider_api_scripts/resources/wikimedia/prettify.sh
+++ b/tests/dags/providers/provider_api_scripts/resources/wikimedia/prettify.sh
@@ -1,5 +1,5 @@
#!/bin/bash
T=$(mktemp)
-jq '.' $1 > $T
-mv $T $1
+jq '.' "$1" > "$T"
+mv "$T" "$1"