Skip to content

Commit

Permalink
metrics renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 22, 2023
1 parent 984f8ab commit 2e557f9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions metrics/cloc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ output=$2
out=$(cloc --timeout 0 --quiet --csv "${java}" | tail -1)
IFS=',' read -r -a M <<< "${out}"
cat <<EOT> "${output}"
blanks ${M[2]} Blank Lines
comments ${M[3]} Commenting Lines
nobl ${M[2]} Number of Blank Lines
nocl ${M[3]} Number of Commenting Lines
loc ${M[4]} Lines Of Code
EOT
6 changes: 3 additions & 3 deletions metrics/multimetric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ temp="${TARGET}/temp/multimetric.json"
mkdir -p "$(dirname "${temp}")"
echo "${body}" > "${temp}"
cat <<EOT> "${output}"
hsdif $(echo "${body}" | jq '.halstead_difficulty' | "${LOCAL}/help/float.sh") Halstead Difficulty
hsef $(echo "${body}" | jq '.halstead_effort' | "${LOCAL}/help/float.sh") Halstead Effort
hsvol $(echo "${body}" | jq '.halstead_volume' | "${LOCAL}/help/float.sh") Halstead Volume
hsd $(echo "${body}" | jq '.halstead_difficulty' | "${LOCAL}/help/float.sh") Halstead Difficulty
hse $(echo "${body}" | jq '.halstead_effort' | "${LOCAL}/help/float.sh") Halstead Effort
hsv $(echo "${body}" | jq '.halstead_volume' | "${LOCAL}/help/float.sh") Halstead Volume
midx $(echo "${body}" | jq '.maintainability_index' | "${LOCAL}/help/float.sh") Maintainability Index
fout $(echo "${body}" | jq '.fanout_external' | "${LOCAL}/help/float.sh") Fan-Out
EOT
2 changes: 2 additions & 0 deletions tests/metrics/test-cloc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ stdout=$2
echo "class Foo {}" > "${java}"
"${LOCAL}/metrics/cloc.sh" "${java}" "${temp}/stdout"
grep "loc 1" "${temp}/stdout"
grep "nobl 0" "${temp}/stdout"
grep "nocl 0" "${temp}/stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly counted lines of code"
6 changes: 3 additions & 3 deletions tests/metrics/test-multimetric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ EOT
"${LOCAL}/metrics/multimetric.sh" "${java}" "${temp}/stdout"
cat "${TARGET}/temp/multimetric.json"
cat "${temp}/stdout"
grep "hsdif 6" "${temp}/stdout"
grep "hsef 1133.218" "${temp}/stdout"
grep "hsvol 188.87" "${temp}/stdout"
grep "hsd 6" "${temp}/stdout"
grep "hse 1133.218" "${temp}/stdout"
grep "hsv 188.87" "${temp}/stdout"
grep "midx 100" "${temp}/stdout"
grep "fout 2" "${temp}/stdout"
} > "${stdout}" 2>&1
Expand Down
20 changes: 16 additions & 4 deletions tests/steps/test-measure-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,33 @@ stdout=$2
}
EOT
msg=$("${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m")
set -x
echo "${msg}"
test "$(echo "${msg}" | grep -c "sum=0")" = 0
test "$(find "${temp}" -name 'm.*' -type f | wc -l | xargs)" = "34"
all=$(find "${temp}" -name 'm.*' -type f -exec basename {} \;)
test "$(echo "${all}" | wc -l | xargs)" = "34"
echo "${all}" | sort | while IFS= read -r m; do
metric=${m//m\./}
echo "${metric}: $(cat "${temp}/${m}")"
done
set -x
test "$(cat "${temp}/m.loc")" = "8"
test "$(cat "${temp}/m.comments")" = "1"
test "$(cat "${temp}/m.nocl")" = "1"
test "$(cat "${temp}/m.cc")" = "1"
test "$(cat "${temp}/m.ncss")" = "7"
test "$(cat "${temp}/m.nocm")" = "0"
test "$(cat "${temp}/m.noom")" = "1"
test "$(cat "${temp}/m.nocc")" = "1"
test "$(cat "${temp}/m.napc")" = "1"
test "$(cat "${temp}/m.noii")" = "1"
test "$(cat "${temp}/m.notp")" = "0"
test "$(cat "${temp}/m.final")" = "0"
test "$(cat "${temp}/m.blanks")" = "1"
test "$(cat "${temp}/m.nobl")" = "1"
test "$(cat "${temp}/m.hsd")" = "6.188"
test "$(cat "${temp}/m.hsv")" = "122.624"
test "$(cat "${temp}/m.hse")" = "758.735"
test "$(cat "${temp}/m.coco")" = "0"
test "$(cat "${temp}/m.fout")" = "0"
test "$(cat "${temp}/m.LCOM5")" = "0"
set +x
} > "${stdout}" 2>&1
echo "👍🏻 Single file measured correctly"

0 comments on commit 2e557f9

Please sign in to comment.