Skip to content

Commit

Permalink
remove class name from metric and test
Browse files Browse the repository at this point in the history
  • Loading branch information
IlnurHA committed Apr 25, 2024
1 parent e8e0762 commit 841294d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions metrics/hoc.sh
Expand Up @@ -25,16 +25,15 @@ set -o pipefail

java=$1
output=$(realpath "$2")
class_name=$3

cd "$(dirname "${java}")"
base=$(basename "${java}")

# To check that file was added in commit any time
if git status > /dev/null 2>&1 && test -n "$(git log --oneline -- "${base}")"; then
hoc=$(git log -L:"class\s${class_name}:${java}" | grep -E "^[+-].*$" | grep -Ev "^\-\-\-\s\S+$" | grep -Evc "^\+\+\+\s\S+$")
hoc=$(git log -L:"class\s:${java}" | grep -E "^[+-].*$" | grep -Ev "^\-\-\-\s\S+$" | grep -Evc "^\+\+\+\s\S+$")
else
hoc=0
fi

echo "hoc ${hoc} Hits Of Code for ${class_name} class" > "${output}"
echo "hoc ${hoc} Hits Of Code for file" > "${output}"
6 changes: 3 additions & 3 deletions tests/metrics/test-hoc.sh
Expand Up @@ -50,19 +50,19 @@ stdout=$2
printf "class Foo {}" > "${java}"
git add "${java}"
git commit --quiet -m "first commit"
${hoc_script_path} "${java}" "stdout" "Foo"
${hoc_script_path} "${java}" "stdout"
grep "hoc 1" "stdout"

printf "class Foo {\n\tint x;\n\tbool y;\n}\n" > "${java}"
git add "${java}"
git commit --quiet -m "+second commit"
${hoc_script_path} "${java}" "stdout" "Foo"
${hoc_script_path} "${java}" "stdout"
grep "hoc 6" "stdout"

printf "class Foo {\n\tbool z;\n}\n" > "${java}"
git add "${java}"
git commit --quiet -m "-third commit"
${hoc_script_path} "${java}" "stdout" "Foo"
${hoc_script_path} "${java}" "stdout"
grep "hoc 9" "stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly calculated hits of code"

0 comments on commit 841294d

Please sign in to comment.