Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.2.2
4 changes: 2 additions & 2 deletions lib/bashcov/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Lexer
IGNORE_END_WITH = %w[(].freeze

# Lines containing only one of these keywords are irrelevant for coverage
IGNORE_IS = %w[esac if then else elif fi while do done { } ;;].freeze
IGNORE_IS = %w[esac if then else elif fi while do done { } ;; ( )].freeze

# @param [String] filename File to analyze
# @param [Hash] coverage Coverage with executed lines marked
Expand Down Expand Up @@ -104,7 +104,7 @@ def relevant?(line)
line.start_with?(*IGNORE_START_WITH) ||
line.end_with?(*IGNORE_END_WITH)

return false if line =~ /\A[a-zA-Z_][a-zA-Z0-9_\-:\.]*\(\)/ # function declared without the `function` keyword
return false if line =~ /\A[a-zA-Z_@][a-zA-Z0-9_@\-:\.]*\(\)/ # function declared without the `function` keyword
return false if line =~ /\A[^)]+\)\Z/ # case statement selector, e.g. `--help)`

true
Expand Down
4 changes: 2 additions & 2 deletions spec/support/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def expected_coverage
"#{test_app}/scripts/cd.sh" => [nil, nil, 1, 2, nil, 3, 1, 3, nil, 2, nil, nil, 1, nil, 3, nil, 6, nil, 1, nil, 1],
"#{test_app}/scripts/comments.sh" => [nil, nil, 1, nil, 1, nil, nil, nil, 1, nil, 1],
"#{test_app}/scripts/delete.sh" => [nil, nil, 1, 1, 1, 1, nil, 1, 1],
"#{test_app}/scripts/function.sh" => [nil, nil, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil, nil, 1, nil, nil, nil, 0, nil, nil, nil, 1, nil, nil, 1, 1, 1, 1],
"#{test_app}/scripts/function.sh" => [nil, nil, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil, nil, 1, nil, nil, nil, 0, nil, nil, nil, 0, nil, nil, 1, 1, 1, 1],
"#{test_app}/scripts/long_line.sh" => [nil, nil, 1, 1, 1, 0],
"#{test_app}/scripts/nested/simple.sh" => [nil, nil, nil, nil, 1, 1, nil, 0, nil, nil, 1],
"#{test_app}/scripts/new\nline.sh" => [nil, nil, 1, nil, 2],
Expand All @@ -31,7 +31,7 @@ def expected_coverage
"#{test_app}/scripts/source.sh" => [nil, nil, 1, nil, 2],
"#{test_app}/scripts/sourced.txt" => [nil, nil, 1],
"#{test_app}/scripts/unicode.sh" => [nil, nil, nil, 1, nil, 1],
"#{test_app}/scripts/multiline.sh" => [nil, nil, nil, 1, nil, 0, nil, 1, nil, 1, nil, 0, nil, nil, 1, 2, 1, 1, 0, nil, nil, 2, nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, 1],
"#{test_app}/scripts/multiline.sh" => [nil, nil, nil, 1, nil, 0, nil, 1, nil, 1, nil, 0, nil, nil, 1, 2, 1, 1, 0, nil, nil, 2, nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, nil, 1],
"#{test_app}/scripts/multiline2.sh" => [nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, 1, 1, 1, nil, 1, 1, 1, nil, 1, nil, nil, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, nil, nil, 1],
"#{test_app}/scripts/multiline3.sh" => [nil, nil, 1, 1, 1, 1],
"#{test_app}/scripts/multiline4.sh" => [nil, nil, 1, 1],
Expand Down
4 changes: 2 additions & 2 deletions spec/test_app/scripts/function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ put-team-key() {
echo put-team-key # 0
}

abc::def.fn() {
abc::def.@fn() {
echo "${FUNCNAME[0]}" # 1
}

f1 # 1
f2 # 1
__a-bc # 1
abc::def.fn # 1
abc::def.@fn # 1
4 changes: 3 additions & 1 deletion spec/test_app/scripts/multiline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ hello
there
'
# nil
echo the end # 1
( # nil
echo the end # 1
) # nil
Loading