Skip to content

Commit bd9ba6f

Browse files
committed
fix: linter
1 parent 1d48963 commit bd9ba6f

File tree

14 files changed

+93
-55
lines changed

14 files changed

+93
-55
lines changed

src/assert.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ function assert_successful_code() {
433433
local label
434434
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
435435
bashunit::assert::mark_failed
436-
bashunit::console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
436+
bashunit::console_results::print_failed_test \
437+
"${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
437438
return
438439
fi
439440

@@ -469,7 +470,8 @@ function assert_general_error() {
469470
local label
470471
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
471472
bashunit::assert::mark_failed
472-
bashunit::console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
473+
bashunit::console_results::print_failed_test \
474+
"${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
473475
return
474476
fi
475477

@@ -488,7 +490,8 @@ function assert_command_not_found() {
488490
local label
489491
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
490492
bashunit::assert::mark_failed
491-
bashunit::console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
493+
bashunit::console_results::print_failed_test \
494+
"${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}"
492495
return
493496
fi
494497

src/console_header.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ EOF
4949
fi
5050

5151
if [ "$total_tests" -eq 0 ]; then
52-
printf "${_BASHUNIT_COLOR_BOLD}${_BASHUNIT_COLOR_PASSED}bashunit${_BASHUNIT_COLOR_DEFAULT} - %s\n" "$BASHUNIT_VERSION"
52+
printf "%s%sbashunit%s - %s\n" \
53+
"$_BASHUNIT_COLOR_BOLD" "$_BASHUNIT_COLOR_PASSED" "$_BASHUNIT_COLOR_DEFAULT" "$BASHUNIT_VERSION"
5354
else
5455
printf "${_BASHUNIT_COLOR_BOLD}${_BASHUNIT_COLOR_PASSED}bashunit${_BASHUNIT_COLOR_DEFAULT} - %s | Tests: %s\n"\
5556
"$BASHUNIT_VERSION"\

src/console_results.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ function bashunit::console_results::print_successful_test() {
152152
quoted_args="$quoted_args, '$arg'"
153153
fi
154154
done
155-
line=$(printf "%s✓ Passed%s: %s (%s)" "$_BASHUNIT_COLOR_PASSED" "$_BASHUNIT_COLOR_DEFAULT" "$test_name" "$quoted_args")
155+
line=$(printf "%s✓ Passed%s: %s (%s)" \
156+
"$_BASHUNIT_COLOR_PASSED" "$_BASHUNIT_COLOR_DEFAULT" "$test_name" "$quoted_args")
156157
fi
157158

158159
local full_line=$line

src/env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ CAT="$(command -v cat)"
175175

176176
# Initialize temp directory once at startup for performance
177177
BASHUNIT_TEMP_DIR="${TMPDIR:-/tmp}/bashunit/tmp"
178-
mkdir -p -m 777 "$BASHUNIT_TEMP_DIR"
178+
mkdir -p "$BASHUNIT_TEMP_DIR" 2>/dev/null || true
179179

180180
if bashunit::env::is_dev_mode_enabled; then
181181
bashunit::internal_log "info" "Dev log enabled" "file:$BASHUNIT_DEV_LOG"

src/learn.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ function bashunit::learn::show_progress() {
137137

138138
if [[ $completed -eq $total_lessons ]]; then
139139
echo ""
140-
echo "${_BASHUNIT_COLOR_PASSED}${_BASHUNIT_COLOR_BOLD}🎉 Congratulations! You've completed all lessons!${_BASHUNIT_COLOR_DEFAULT}"
140+
echo "${_BASHUNIT_COLOR_PASSED}${_BASHUNIT_COLOR_BOLD}"\
141+
"🎉 Congratulations! You've completed all lessons!${_BASHUNIT_COLOR_DEFAULT}"
141142
fi
142143

143144
read -p "Press Enter to continue..." -r
@@ -183,7 +184,8 @@ function bashunit::learn::run_lesson_test() {
183184

184185
if "$BASHUNIT_ROOT_DIR/bashunit" "$test_file" --simple; then
185186
echo ""
186-
echo "${_BASHUNIT_COLOR_PASSED}${_BASHUNIT_COLOR_BOLD}✓ Excellent! Lesson $lesson_number completed!${_BASHUNIT_COLOR_DEFAULT}"
187+
echo "${_BASHUNIT_COLOR_PASSED}${_BASHUNIT_COLOR_BOLD}"\
188+
"✓ Excellent! Lesson $lesson_number completed!${_BASHUNIT_COLOR_DEFAULT}"
187189
bashunit::learn::mark_completed "lesson_$lesson_number"
188190
read -p "Press Enter to continue..." -r
189191
return 0
@@ -232,7 +234,8 @@ EOF
232234

233235
local default_file="tests/first_test.sh"
234236
echo ""
235-
printf "When ready, enter file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
237+
printf "When ready, enter file path %s[%s]%s: " \
238+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
236239
read -r test_file
237240
test_file="${test_file:-$default_file}"
238241

@@ -305,7 +308,8 @@ EOF
305308

306309
local default_file="tests/assertions_test.sh"
307310
echo ""
308-
printf "When ready, enter file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
311+
printf "When ready, enter file path %s[%s]%s: " \
312+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
309313
read -r test_file
310314
test_file="${test_file:-$default_file}"
311315

@@ -391,7 +395,8 @@ EOF
391395

392396
local default_file="tests/lifecycle_test.sh"
393397
echo ""
394-
printf "When ready, enter file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
398+
printf "When ready, enter file path %s[%s]%s: " \
399+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
395400
read -r test_file
396401
test_file="${test_file:-$default_file}"
397402

@@ -486,7 +491,8 @@ EOF
486491

487492
local default_file="tests/calculator_test.sh"
488493
echo ""
489-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
494+
printf "When ready, enter TEST file path %s[%s]%s: " \
495+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
490496
read -r test_file
491497
test_file="${test_file:-$default_file}"
492498

@@ -576,7 +582,8 @@ EOF
576582

577583
local default_file="tests/greeter_test.sh"
578584
echo ""
579-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
585+
printf "When ready, enter TEST file path %s[%s]%s: " \
586+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
580587
read -r test_file
581588
test_file="${test_file:-$default_file}"
582589

@@ -667,7 +674,8 @@ EOF
667674

668675
local default_file="tests/system_info_test.sh"
669676
echo ""
670-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
677+
printf "When ready, enter TEST file path %s[%s]%s: " \
678+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
671679
read -r test_file
672680
test_file="${test_file:-$default_file}"
673681

@@ -780,7 +788,8 @@ EOF
780788

781789
local default_file="deploy_test.sh"
782790
echo ""
783-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
791+
printf "When ready, enter TEST file path %s[%s]%s: " \
792+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
784793
read -r test_file
785794
test_file="${test_file:-$default_file}"
786795

@@ -893,7 +902,8 @@ EOF
893902

894903
local default_file="validator_test.sh"
895904
echo ""
896-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
905+
printf "When ready, enter TEST file path %s[%s]%s: " \
906+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
897907
read -r test_file
898908
test_file="${test_file:-$default_file}"
899909

@@ -1012,7 +1022,8 @@ EOF
10121022

10131023
local default_file="checker_test.sh"
10141024
echo ""
1015-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
1025+
printf "When ready, enter TEST file path %s[%s]%s: " \
1026+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
10161027
read -r test_file
10171028
test_file="${test_file:-$default_file}"
10181029

@@ -1105,7 +1116,8 @@ EOF
11051116

11061117
local default_file="backup_test.sh"
11071118
echo ""
1108-
printf "When ready, enter TEST file path %s[%s]%s: " "${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
1119+
printf "When ready, enter TEST file path %s[%s]%s: " \
1120+
"${_BASHUNIT_COLOR_FAINT}" "$default_file" "${_BASHUNIT_COLOR_DEFAULT}"
11091121
read -r test_file
11101122
test_file="${test_file:-$default_file}"
11111123

src/main.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ function bashunit::main::exec_benchmarks() {
373373
}
374374

375375
function bashunit::main::cleanup() {
376-
printf "%sCaught Ctrl-C, killing all child processes...%s\n" "${_BASHUNIT_COLOR_SKIPPED}" "${_BASHUNIT_COLOR_DEFAULT}"
376+
printf "%sCaught Ctrl-C, killing all child processes...%s\n" \
377+
"${_BASHUNIT_COLOR_SKIPPED}" "${_BASHUNIT_COLOR_DEFAULT}"
377378
# Kill all child processes of this script
378379
pkill -P $$
379380
bashunit::cleanup_script_temp_files

src/parallel.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ function bashunit::parallel::init() {
112112
}
113113

114114
function bashunit::parallel::is_enabled() {
115-
bashunit::internal_log "bashunit::parallel::is_enabled" "requested:$BASHUNIT_PARALLEL_RUN" "os:${_BASHUNIT_OS:-Unknown}"
115+
bashunit::internal_log "bashunit::parallel::is_enabled" \
116+
"requested:$BASHUNIT_PARALLEL_RUN" "os:${_BASHUNIT_OS:-Unknown}"
116117

117118
if bashunit::env::is_parallel_run_enabled && \
118119
(bashunit::check_os::is_macos || bashunit::check_os::is_ubuntu || bashunit::check_os::is_windows); then

src/runner.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ function bashunit::runner::call_test_functions() {
261261
local filter="$2"
262262
local prefix="test"
263263
# Use cached function names for better performance
264-
local filtered_functions=$(bashunit::helper::get_functions_to_run "$prefix" "$filter" "$_BASHUNIT_CACHED_ALL_FUNCTIONS")
264+
local filtered_functions
265+
filtered_functions=$(bashunit::helper::get_functions_to_run \
266+
"$prefix" "$filter" "$_BASHUNIT_CACHED_ALL_FUNCTIONS")
265267
# shellcheck disable=SC2207
266268
local functions_to_run=($(bashunit::runner::functions_for_script "$script" "$filtered_functions"))
267269

@@ -311,7 +313,9 @@ function bashunit::runner::call_bench_functions() {
311313
local prefix="bench"
312314

313315
# Use cached function names for better performance
314-
local filtered_functions=$(bashunit::helper::get_functions_to_run "$prefix" "$filter" "$_BASHUNIT_CACHED_ALL_FUNCTIONS")
316+
local filtered_functions
317+
filtered_functions=$(bashunit::helper::get_functions_to_run \
318+
"$prefix" "$filter" "$_BASHUNIT_CACHED_ALL_FUNCTIONS")
315319
# shellcheck disable=SC2207
316320
local functions_to_run=($(bashunit::runner::functions_for_script "$script" "$filtered_functions"))
317321

src/upgrade.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function bashunit::upgrade::upgrade() {
1414
echo "> Upgrading bashunit to latest version"
1515
cd "$script_path" || exit
1616

17-
if ! bashunit::io::download_to "https://github.com/TypedDevs/bashunit/releases/download/$latest_tag/bashunit" "bashunit"; then
17+
local url="https://github.com/TypedDevs/bashunit/releases/download/$latest_tag/bashunit"
18+
if ! bashunit::io::download_to "$url" "bashunit"; then
1819
echo "Failed to download bashunit"
1920
fi
2021

tests/unit/assert_test.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ function test_successful_assert_contains_ignore_case() {
148148
}
149149

150150
function test_unsuccessful_assert_contains_ignore_case() {
151-
assert_same\
152-
"$(bashunit::console_results::print_failed_test "Unsuccessful assert contains ignore case" "GNU/LINUX" "to contain" "Unix")"\
153-
"$(assert_contains_ignore_case "Unix" "GNU/LINUX")"
151+
local expected
152+
expected="$(bashunit::console_results::print_failed_test \
153+
"Unsuccessful assert contains ignore case" "GNU/LINUX" "to contain" "Unix")"
154+
assert_same "$expected" "$(assert_contains_ignore_case "Unix" "GNU/LINUX")"
154155
}
155156

156157
function test_successful_assert_contains() {
@@ -168,9 +169,10 @@ function test_successful_assert_not_contains() {
168169
}
169170

170171
function test_unsuccessful_assert_not_contains() {
171-
assert_same\
172-
"$(bashunit::console_results::print_failed_test "Unsuccessful assert not contains" "GNU/Linux" "to not contain" "Linux")"\
173-
"$(assert_not_contains "Linux" "GNU/Linux")"
172+
local expected
173+
expected="$(bashunit::console_results::print_failed_test \
174+
"Unsuccessful assert not contains" "GNU/Linux" "to not contain" "Linux")"
175+
assert_same "$expected" "$(assert_not_contains "Linux" "GNU/Linux")"
174176
}
175177

176178
function test_successful_assert_matches() {
@@ -188,9 +190,10 @@ function test_successful_assert_not_matches() {
188190
}
189191

190192
function test_unsuccessful_assert_not_matches() {
191-
assert_same\
192-
"$(bashunit::console_results::print_failed_test "Unsuccessful assert not matches" "GNU/Linux" "to not match" ".*Linu*")"\
193-
"$(assert_not_matches ".*Linu*" "GNU/Linux")"
193+
local expected
194+
expected="$(bashunit::console_results::print_failed_test \
195+
"Unsuccessful assert not matches" "GNU/Linux" "to not match" ".*Linu*")"
196+
assert_same "$expected" "$(assert_not_matches ".*Linu*" "GNU/Linux")"
194197
}
195198

196199
function test_successful_assert_exit_code() {
@@ -260,9 +263,10 @@ function test_unsuccessful_assert_unsuccessful_code() {
260263
return 0
261264
}
262265

263-
assert_same\
264-
"$(bashunit::console_results::print_failed_test "Unsuccessful assert unsuccessful code" "0" "to be non-zero" "but was 0")"\
265-
"$(assert_unsuccessful_code "$(fake_function)")"
266+
local expected
267+
expected="$(bashunit::console_results::print_failed_test \
268+
"Unsuccessful assert unsuccessful code" "0" "to be non-zero" "but was 0")"
269+
assert_same "$expected" "$(assert_unsuccessful_code "$(fake_function)")"
266270
}
267271

268272
function test_successful_assert_general_error() {

0 commit comments

Comments
 (0)