Add bash script style checker to pep8 check

Added the bashate script style checker to the pep8
check target in tox.ini. It actually found two valid
issues - a bad function declaration and a local variable
issue, but mostly just indentation noise. Fixed all the
complaints.

Change-Id: I43b60e7dcf53acf259c8a52b248fbb8c63d3c8d4
This commit is contained in:
Brian Haley 2019-10-10 13:54:58 -04:00
parent ca80bc9e03
commit 98448dce44
8 changed files with 86 additions and 67 deletions

View File

@ -204,7 +204,7 @@ function create_octavia_accounts {
# This is imporant for concurrent tempest testing
openstack quota set --secgroups 100 $SERVICE_PROJECT_NAME
local octavia_service=$(get_or_create_service "octavia" \
octavia_service=$(get_or_create_service "octavia" \
$OCTAVIA_SERVICE_TYPE "Octavia Load Balancing Service")
if [[ "$WSGI_MODE" == "uwsgi" ]] && [[ "$OCTAVIA_NODE" == "main" ]] ; then

View File

@ -18,7 +18,7 @@ source ${TOP_DIR}/stackrc
DEST=${DEST:-/opt/stack}
# Polling functions
function wait_for_loadbalancer_active() {
function wait_for_loadbalancer_active {
lb_name=$1
while [ $(openstack loadbalancer show $lb_name -f value -c provisioning_status) != "ACTIVE" ]; do
sleep 2

View File

@ -21,8 +21,7 @@ PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
# $3..n: command with arguments and parameters
# TODO(cgoncalves): set timeout
function _wait_for_status {
while :
do
while true; do
eval $("${@:3}" -f shell -c provisioning_status -c operating_status)
[[ $operating_status == "ONLINE" && $provisioning_status == "ACTIVE" ]] && break
if [ $provisioning_status == "ERROR" ]; then

View File

@ -1,4 +1,6 @@
#!/bin/sh -v
Body=$(hostname)
Response="HTTP/1.1 200 OK\r\nContent-Length: ${#Body}\r\n\r\n$Body"
while true ; do echo -e $Response | nc -llp 80; done
while true; do
echo -e $Response | nc -llp 80
done

View File

@ -7,6 +7,7 @@ astroid==1.3.8
automaton==1.14.0
Babel==2.3.4
bandit==1.4.0
bashate==0.5.1
bcrypt==3.1.4
beautifulsoup4==4.6.0
cachetools==2.0.1

View File

@ -21,3 +21,4 @@ tempest>=17.1.0 # Apache-2.0
# Required for pep8 - doc8 tests
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
bashate>=0.5.1 # Apache-2.0

16
tox.ini
View File

@ -86,9 +86,11 @@ commands = flake8
python -m unittest specs-tests.test_titles
sh ./tools/misc-sanity-checks.sh
{toxinidir}/tools/coding-checks.sh --pylint {posargs}
{[testenv:bashate]commands}
whitelist_externals =
sh
find
bash
[testenv:docs]
basepython = python3
@ -166,6 +168,20 @@ import-order-style = pep8
# [H904]: Delay string interpolations at logging calls
enable-extensions=H106,H203,H204,H205,H904
[testenv:bashate]
basepython = python3
envdir = {toxworkdir}/shared
commands = bash -c "find {toxinidir} \
-not \( -type d -name .tox\* -prune \) \
-not \( -type d -name .venv\* -prune \) \
-type f \
-name \*.sh \
# [E005]: File does not begin with #! or have a .sh prefix
# [E006]: Check for lines longer than 79 columns
# [E042]: Local declaration hides errors
# [E043]: Arithmetic compound has inconsistent return semantics
-print0 | xargs -0 bashate -v -iE006 -eE005,E042,E043"
[hacking]
import_exceptions = octavia.i18n
local-check-factory = octavia.hacking.checks.factory