Skip to content

Commit c9cc531

Browse files
committed
fix: incorrect log about fixed issues
1 parent 0b37fe0 commit c9cc531

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/summary.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ Scanned/Changed scripts: \`${#list_of_changed_scripts[@]}\`
7272
get_number_of () {
7373
[[ $# -le 0 ]] && return 1
7474

75-
jq '.defects | length' "../${1}.log"
75+
file="../${1}.log"
76+
[[ -s "${file}" ]] || return 1
77+
78+
jq '.defects | length' "${file}"
7679
}
7780

7881
# Create full Markdown style link to results

src/validation.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ get_fixes () {
1919
# It expects file '../fixes.log' to contain fixes
2020
# $? - return value is always 0
2121
evaluate_and_print_fixes () {
22-
if [[ -s ../fixes.log ]]; then
22+
gather_statistics "../fixes.log"
23+
24+
num_of_fixes=$(get_number_of fixes)
25+
if [[ "${num_of_fixes}" -gt 0 ]]; then
2326
echo -e "${GREEN}Fixed defects${NOCOLOR}"
2427
csgrep --embed-context 2 ../fixes.log
2528
else
@@ -45,7 +48,7 @@ evaluate_and_print_defects () {
4548
gather_statistics "../defects.log"
4649

4750
num_of_defects=$(get_number_of defects)
48-
if [[ -s ../defects.log ]] && [[ "${num_of_defects}" -gt 0 ]] ; then
51+
if [[ "${num_of_defects}" -gt 0 ]] ; then
4952
print_statistics
5053

5154
echo -e "${YELLOW}Defects, NEEDS INSPECTION${NOCOLOR}"

test/get_number_of.bats

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ setup () {
1717
assert_failure 1
1818
}
1919

20+
@test "get_number_of() - No such file or directory" {
21+
source "${PROJECT_ROOT}/src/summary.sh"
22+
23+
run get_number_of "asdfsghdfadshgfadsdshgfadsfghfjdsdf.log"
24+
assert_failure 1
25+
}
26+
2027
@test "get_number_of() - defects" {
2128
source "${PROJECT_ROOT}/src/summary.sh"
2229

0 commit comments

Comments
 (0)