Skip to content

Commit 6909960

Browse files
[STYLE] Various fixes for linters.
Changes in file docs/FAQ.md: - minor change to ensure style in example. Changes in file docs/conf.py: - various Flake8 style fixes. Changes in file tests/check_cc_lines: - various style fixes Changes in file tests/check_codecov: - various style fixes Changes in file tests/check_integration_coverage: - various style fixes Changes in file tests/check_legacy_setup_coverage: - various style fixes Changes in file tests/check_pip: - various style fixes Changes in file tests/check_spelling: - various style fixes Changes in file tests/test_manifest.py: - fix for indentation.
1 parent fd725bf commit 6909960

File tree

9 files changed

+60
-30
lines changed

9 files changed

+60
-30
lines changed

docs/FAQ.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ work so far as this Multicast module is concerned.
243243
to the specific commit you're working on, set the `DOCS_BUILD_REF` environment variable:
244244

245245
```bash
246+
# shellcheck disable=SC2155
246247
export DOCS_BUILD_REF=$("${GIT:-git}" rev-parse --verify HEAD)
247248
make build-docs # or your own documentation build command
248249
```

docs/conf.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
# add these directories to sys.path here. If the directory is relative to the
4545
# documentation root, use os.path.abspath to make it absolute, like shown here.
4646
sys.path.insert(0, os.path.abspath(""".."""))
47-
from docs.utils import _validate_git_ref
48-
from docs.utils import slugify_header
47+
from docs.utils import _validate_git_ref # noqa
48+
from docs.utils import slugify_header # noqa
4949

5050
# Define the branch reference for linkcode_resolve
5151
DOCS_BUILD_REF: str = _validate_git_ref(os.environ.get("DOCS_BUILD_REF", "stable"))
@@ -284,7 +284,7 @@
284284
# html_use_opensearch = ''
285285

286286
# This is the file name suffix for HTML files (e.g. ".xhtml").
287-
#html_file_suffix = ".html"
287+
# html_file_suffix = ".html"
288288

289289
# Output file base name for HTML help builder.
290290
htmlhelp_basename = "multicast_doc"
@@ -398,13 +398,13 @@
398398
# dir menu entry, description, category)
399399
texinfo_documents = [
400400
(
401-
"index",
402-
"Multicast",
403-
"Multicast Documentation",
404-
"reactive-firewall",
405-
"Multicast",
406-
"Multicast Python Module.",
407-
"Miscellaneous"
401+
"index",
402+
"Multicast",
403+
"Multicast Documentation",
404+
"reactive-firewall",
405+
"Multicast",
406+
"Multicast Python Module.",
407+
"Miscellaneous"
408408
),
409409
]
410410

@@ -425,8 +425,8 @@
425425

426426
extlinks = {
427427
"""issue""": (
428-
f"{linkcode_url_prefix}/{suffix}",
429-
"""issue #%s"""
428+
f"{linkcode_url_prefix}/{suffix}",
429+
"""issue #%s"""
430430
)
431431
}
432432

tests/check_cc_lines

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ EXIT_CODE=1
8080
function check_command() {
8181
test -z "$1" && { printf "%s\n" "Error: command name is required to check for existence." >&2 ; exit 64 ; } ;
8282
local cmd="$1" ;
83+
# shellcheck disable=SC2086
8384
test -x "$(command -v ${cmd})" || { printf "%s\n" "Error: Required command '$cmd' is not found." >&2 ; exit 126 ; } ;
8485
} # end check_command()
8586
# propagate/export function to sub-shells
@@ -97,7 +98,11 @@ check_command shlock ;
9798

9899

99100
function cleanup() {
100-
rm -f "${LOCK_FILE}" 2>/dev/null || true ; wait ;
101+
# shellcheck disable=SC2317
102+
rm -f "${LOCK_FILE}" 2>/dev/null || true ;
103+
# shellcheck disable=SC2317
104+
wait ;
105+
# shellcheck disable=SC2317
101106
hash -d shlock 2>/dev/null > /dev/null || true ;
102107
}
103108

tests/check_codecov

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ EXIT_CODE=0
8383
function check_command() {
8484
test -z "$1" && { printf "%s\n" "Error: command name is required to check for existence." >&2 ; exit 64 ; } ;
8585
local cmd="$1" ;
86+
# shellcheck disable=SC2086
8687
test -x "$(command -v ${cmd})" || { printf "%s\n" "Error: Required command '$cmd' is not found." >&2 ; exit 126 ; } ;
8788
} # end check_command()
8889
# propagate/export function to sub-shells
@@ -106,12 +107,19 @@ else
106107
fi
107108

108109
function cleanup() {
109-
rm -f "${LOCK_FILE}" 2>/dev/null || true ; wait ;
110-
rm -f ./codecov 2>/dev/null || true ; wait ;
110+
# shellcheck disable=SC2317
111+
rm -f "${LOCK_FILE}" 2>/dev/null || true ;
112+
# shellcheck disable=SC2317
113+
wait ;
114+
# shellcheck disable=SC2317
115+
rm -f ./codecov 2>/dev/null || true ;
116+
# shellcheck disable=SC2317
117+
wait ;
118+
# shellcheck disable=SC2317
111119
hash -d shlock 2>/dev/null > /dev/null || true ;
112120
}
113121

114-
if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
122+
if [[ ( $(shlock -f "${LOCK_FILE}" -p $$ ) -eq 0 ) ]] ; then
115123
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129
116124
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
117125
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131
@@ -144,6 +152,7 @@ fi
144152
# This File MUST BE GIT-IGNORED
145153
# to be SAFELY USED to store Tokens and env vars (update logic as needed)
146154
if [[ ( -r ./codecov_env ) ]] ; then
155+
# shellcheck disable=SC1091
147156
source ./codecov_env 2>/dev/null || true ;
148157
fi
149158

tests/check_integration_coverage

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ ulimit -t 60
6666
umask 137
6767

6868
# exported Env vars
69+
# shellcheck disable=SC2155
6970
export LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}"
7071

7172
# Function to check if a command exists.
@@ -81,6 +82,7 @@ export LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}"
8182
function check_command() {
8283
test -z "$1" && { printf "%s\n" "Error: command name is required to check for existence." >&2 ; exit 64 ; } ;
8384
local cmd="$1" ;
85+
# shellcheck disable=SC2086
8486
test -x "$(command -v ${cmd})" || { printf "%s\n" "Error: Required command '$cmd' is not found." >&2 ; exit 126 ; } ;
8587
} # end check_command()
8688
# propagate/export function to sub-shells
@@ -116,6 +118,7 @@ if [[ ( $(shlock -f "${LOCK_FILE}" -p $$ ) -eq 0 ) ]] ; then
116118
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
117119
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131
118120
# SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
121+
# shellcheck disable=SC2173
119122
#trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7
120123
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130
121124
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137
@@ -141,7 +144,10 @@ fi
141144

142145
TEST_MCAST_PORT=$(((RANDOM % 16384) + 49152));
143146
TEST_MCAST_GROUP='224.0.0.1' ;
144-
export COVERAGE_CMD="$(command -v python3) -m coverage run --source=multicast -p -m"
147+
PY_3_CMD=$(command -v python3);
148+
# shellcheck disable=SC2086
149+
COVERAGE_CMD="${PY_3_CMD} -m coverage run --source=multicast -p -m"
150+
export COVERAGE_CMD
145151

146152
# start test-suite
147153

tests/check_legacy_setup_coverage

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ ulimit -t 60
9797
# setting the path may break brain-dead CI that uses crazy paths
9898
# PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
9999
umask 137
100-
101-
export LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}"
100+
LC_CTYPE="${LC_CTYPE:-'en_US.UTF-8'}"
101+
export LC_CTYPE
102102

103103
LOCK_FILE="${TMPDIR:-/tmp}/org.pak.multicast.cov-legacy-setup-shell"
104104
EXIT_CODE=1
@@ -143,7 +143,7 @@ function cleanup() {
143143
hash -d shlock 2>/dev/null > /dev/null || true ;
144144
}
145145

146-
if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
146+
if [[ ( $(shlock -f "${LOCK_FILE}" -p $$ ) -eq 0 ) ]] ; then
147147
EXIT_CODE=0
148148
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129
149149
trap 'cleanup 2>/dev/null || rm -f "${LOCK_FILE}" 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
@@ -173,10 +173,11 @@ else
173173
fi
174174

175175
if [[ ( -x $(command -v python3) ) ]] ; then
176-
export COVERAGE_CMD="$(command -v python3) -m coverage run --include=setup.py -p"
176+
COVERAGE_CMD="$(command -v python3) -m coverage run --include=setup.py -p"
177177
elif [[ ( -x $(command -v coverage) ) ]] ; then
178-
export COVERAGE_CMD="$(command -v coverage) run --include=setup.py -p"
178+
COVERAGE_CMD="$(command -v coverage) run --include=setup.py -p"
179179
fi
180+
export COVERAGE_CMD
180181

181182
make -C "${_TEST_ROOT_DIR}" -j1 -f Makefile test-reports || EXIT_CODE=3 ;
182183
printf "%s\n" "Start of Log:" > "${_TEST_ROOT_DIR}"/"${LOG_FILE}" ; wait ;

tests/check_pip

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ ulimit -t 600
114114
umask 137
115115

116116
# force utf-8 for checking in script
117-
export LC_CTYPE="${LC_CTYPE:-en_US.UTF-8}"
117+
LC_CTYPE="${LC_CTYPE:-en_US.UTF-8}"
118+
export LC_CTYPE
118119
# set remaining variables
119120
LOCK_FILE="${TMPDIR:-/tmp}/org.pak.multicast.pip-check-shell"
120121
# Global variable to track temporary directories
@@ -138,6 +139,7 @@ function check_command() {
138139
"${SCRIPT_FILE}" "${BASH_LINENO:-0}" \
139140
"Error: command name is required to check for existence." >&2 ; exit 64 ;} ;
140141
local cmd="$1" ;
142+
# shellcheck disable=SC2086
141143
test -x "$(command -v ${cmd})" || { printf "::error file=%s,line=%s,title=COMMAND::%s\n" \
142144
"${SCRIPT_FILE}" "${BASH_LINENO:-0}" \
143145
"Error: Required command '$cmd' is not found." >&2 ; exit 126 ;} ;
@@ -149,13 +151,16 @@ export -f check_command
149151
hash -p ./.github/tool_shlock_helper.sh shlock || { printf "%s\n" "Error: Failed to register shlock helper. CEP-5 locking will not work." >&2 ; exit 78 ; } ;
150152

151153
# Check required commands
152-
check_required_commands() {
154+
function check_required_commands() {
153155
local -ra REQUIRED_COMMANDS=("grep" "python3" "git" "mktemp" "sed" "tee" "tr" "cut" "pip")
154156
local cmd
155157
for cmd in "${REQUIRED_COMMANDS[@]}"; do
156158
check_command "${cmd}"
157159
done
158160
}
161+
162+
check_required_commands
163+
159164
if command -v pip-audit >/dev/null 2>&1; then
160165
check_command pip-audit # optional
161166
else
@@ -203,7 +208,8 @@ function handle_signals() {
203208
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129
204209
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
205210
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131
206-
# shellcheck disable=SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
211+
# SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
212+
# shellcheck disable=SC2173
207213
#trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7
208214
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130
209215
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137
@@ -292,6 +298,7 @@ function get_package_list() {
292298

293299
function install_package() {
294300
local pkg="$1"
301+
# shellcheck disable=SC2086
295302
if ! python3 -m pip install $PIP_COMMON_FLAGS $PIP_ENV_FLAGS "${pkg}"; then
296303
printf "::warning file=%s,title=PIP::Failed to install %s\n" "${req_file}" "${pkg}" >&2 ;
297304
return 6
@@ -381,7 +388,7 @@ if [[ ("${EXIT_CODE}" -eq 0) ]] ; then
381388

382389
printf "::debug::%s\n" "Reading from repository ${_TEST_ROOT_DIR} ..." ;
383390
# Get a list of files to check using git ls-tree with filtering (and careful shell globing)
384-
FILES_TO_CHECK=$(git ls-tree -r --full-tree --name-only HEAD -- "${_TEST_ROOT_DIR}"/test/requirements.txt "${_TEST_ROOT_DIR}"/*-requirements.txt "${_TEST_ROOT_DIR}/requirements.txt" 2>/dev/null || EXIT_CODE=3)
391+
FILES_TO_CHECK=$(git ls-tree -r --full-tree --name-only HEAD -- "${_TEST_ROOT_DIR}"/test/requirements.txt "${_TEST_ROOT_DIR}"/*-requirements.txt "${_TEST_ROOT_DIR}/requirements.txt" 2>/dev/null) || EXIT_CODE=3 ;
385392
[[ ( $EXIT_CODE -eq 0 ) ]] || { printf "%s\n" "::error file=${SCRIPT_FILE},line=${BASH_LINENO:-0},title=GIT::Failed to list requirements files using git ls-tree" >&2 ;}
386393

387394
if [[ ("${EXIT_CODE}" -eq 0) ]] ; then

tests/check_spelling

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ ulimit -t 600
9595
umask 137
9696

9797
# force utf-8 for spelling
98-
export LC_CTYPE="${LC_CTYPE:-en_US.UTF-8}"
99-
98+
LC_CTYPE="${LC_CTYPE:-en_US.UTF-8}"
99+
export LC_CTYPE
100100
LOCK_FILE="${TMPDIR:-/tmp}/org.pak.multicast.spell-check-shell"
101101
EXIT_CODE=1
102102

@@ -113,6 +113,7 @@ EXIT_CODE=1
113113
function check_command() {
114114
test -z "$1" && { printf "%s\n" "Error: command name is required to check for existence." >&2 ; exit 64 ; } ;
115115
local cmd="$1" ;
116+
# shellcheck disable=SC2086
116117
test -x "$(command -v ${cmd})" || { printf "%s\n" "Error: Required command '$cmd' is not found." >&2 ; exit 126 ; } ;
117118
} # end check_command()
118119
# propagate/export function to sub-shells

tests/test_manifest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_sdist_includes_required_files(self):
113113
self.assertIn(
114114
expected_file,
115115
members,
116-
f"Missing {str(expected_file)} in sdist."
116+
f"Missing {str(expected_file)} in sdist."
117117
)
118118

119119
def test_sdist_excludes_unwanted_files(self):
@@ -134,7 +134,7 @@ def test_sdist_excludes_unwanted_files(self):
134134
self.assertNotIn(
135135
unwanted_file,
136136
members,
137-
f"Unwanted file {str(unwanted_file)} found in sdist."
137+
f"Unwanted file {str(unwanted_file)} found in sdist."
138138
)
139139

140140

0 commit comments

Comments
 (0)