Closed arielsvn closed 4 years ago
I'm working to configure pre-commit on the project, once that's implemented the configuration to add spellcheck
to the pre-commit is:
- repo: git://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
- id: shell-lint
args: [--format=json]
Sweet! I like this a lot! This is the linter that @wvauclain used to cleanup/standardize all of our bash over the summer, which is probably why there's so few warnings now. (He fixed a lot of things back then.)
This was done in https://github.com/AlexsLemonade/refinebio/pull/2389
Context
Since we have started to add automatic checks for our python code I think it would also make sense to check the script files as well.
Problem or idea
I found shellcheck which looks like it's widely used. I ran it on all the scripts and got a few warnings that look relevant, example:
Full output from `shellcheck ./**/*.sh -e SC2154`
``` In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 13: cd /home/ubuntu ^-------------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. Did you mean: cd /home/ubuntu || exit In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 72: python ./awslogs-agent-setup.py --region ${region} --non-interactive --configfile awslogs.conf ^-------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: python ./awslogs-agent-setup.py --region "${region}" --non-interactive --configfile awslogs.conf In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 105: docker pull ${dockerhub_repo}/${api_docker_image} ^---------------^ SC2086: Double quote to prevent globbing and word splitting. ^-----------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: docker pull "${dockerhub_repo}"/"${api_docker_image}" In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 111: -e DATABASE_HOST=${database_host} \ ^--------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e DATABASE_HOST="${database_host}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 112: -e DATABASE_NAME=${database_name} \ ^--------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e DATABASE_NAME="${database_name}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 113: -e DATABASE_USER=${database_user} \ ^--------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e DATABASE_USER="${database_user}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 114: -e DATABASE_PASSWORD=${database_password} \ ^------------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e DATABASE_PASSWORD="${database_password}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 115: -e ELASTICSEARCH_HOST=${elasticsearch_host} \ ^-------------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e ELASTICSEARCH_HOST="${elasticsearch_host}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 116: -e ELASTICSEARCH_PORT=${elasticsearch_port} \ ^-------------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -e ELASTICSEARCH_PORT="${elasticsearch_port}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 119: --log-opt awslogs-region=${region} \ ^-------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: --log-opt awslogs-region="${region}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 120: --log-opt awslogs-group=${log_group} \ ^----------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: --log-opt awslogs-group="${log_group}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 121: --log-opt awslogs-stream=${log_stream} \ ^-----------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: --log-opt awslogs-stream="${log_stream}" \ In ./infrastructure/api-configuration/api-server-instance-user-data.tpl.sh line 124: -it -d ${dockerhub_repo}/${api_docker_image} /bin/sh -c "/home/user/collect_and_run_uwsgi.sh" ^---------------^ SC2086: Double quote to prevent globbing and word splitting. ^-----------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: -it -d "${dockerhub_repo}"/"${api_docker_image}" /bin/sh -c "/home/user/collect_and_run_uwsgi.sh" In ./infrastructure/cluster_connect.sh line 6: if [ $(cssh -v > /dev/null 2>&1; echo $?) == 0 ]; then ^-- SC2046: Quote this to prevent word splitting. In ./infrastructure/cluster_connect.sh line 7: cssh --options "-i data-refinery-key.pem" --username ubuntu $(Solution or next step
We should look into these errors and fix the ones that might cause problems for us.
shellcheck
can be configured to skip the error codes.