New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metric HOC #188
Merged
Merged
Metric HOC #188
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
24b355c
Hits of code metric
IlnurHA 2b2124e
Update hoc.py
IlnurHA e7b25a0
Shell script instead of python file
IlnurHA ccfcfc0
Test for hoc.sh
IlnurHA 26f1e3e
Fixed test and metric
IlnurHA 0cf9b3c
Rebase problem
IlnurHA 2018969
Merhe test
IlnurHA 2187f75
Merge branch 'yegor256:master' into master
IlnurHA bfd5bdf
Updated HOC
IlnurHA ad51f69
Updated tests for hoc
IlnurHA 4bfeb0b
Fix Pipeline error
IlnurHA 3de4845
Fix access to be executable for make pipeline
IlnurHA 8e8b449
Fixed path for script
IlnurHA d2482bd
Output for hoc to be parsable
IlnurHA 62cc84a
Merge branch 'yegor256:master' into master
IlnurHA 185b868
Fix Test for HOC and comment unused variable
IlnurHA 852ba51
Uncomment temp; It is actually used
IlnurHA e8e0762
Merge branch 'yegor256:master' into master
IlnurHA 841294d
remove class name from metric and test
IlnurHA File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021-2024 Yegor Bugayenko | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
set -e | ||
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+$") | ||
else | ||
hoc=0 | ||
fi | ||
|
||
echo "hoc ${hoc} Hits Of Code for ${class_name} class" > "${output}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @IlnurHA no need to mention the name of the class here, see: https://github.com/yegor256/cam/blob/master/metrics/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2021-2024 Yegor Bugayenko | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
set -e | ||
set -o pipefail | ||
|
||
temp=$1 | ||
stdout=$2 | ||
|
||
{ | ||
hoc_script_path="${LOCAL}/metrics/hoc.sh" | ||
cd "${temp}" | ||
|
||
rm -rf ./* | ||
rm -rf .git | ||
|
||
git init --quiet . | ||
git config user.email 'foo@example.com' | ||
git config user.name 'Foo' | ||
git config commit.gpgsign false | ||
|
||
java_dir="./foo/dir/" | ||
java="FooTest.java" | ||
|
||
mkdir -p "${java_dir}" | ||
cd ${java_dir} | ||
|
||
touch "${java}" | ||
touch "stdout" | ||
|
||
printf "class Foo {}" > "${java}" | ||
git add "${java}" | ||
git commit --quiet -m "first commit" | ||
${hoc_script_path} "${java}" "stdout" "Foo" | ||
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" | ||
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" | ||
grep "hoc 9" "stdout" | ||
} > "${stdout}" 2>&1 | ||
echo "👍🏻 Correctly calculated hits of code" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IlnurHA the name of the class is not provided to this script: https://github.com/yegor256/cam/blob/master/metrics/README.md