Skip to content
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 19 commits into from Apr 25, 2024
Merged

Metric HOC #188

merged 19 commits into from Apr 25, 2024

Conversation

IlnurHA
Copy link
Contributor

@IlnurHA IlnurHA commented Mar 5, 2024

Added HOC metric (Hits of Code), which is the number of commits where the code of a specific class was changed in the git history.

Closes #127

Fix regex to find necessary class
@yegor256
Copy link
Owner

yegor256 commented Mar 5, 2024

@IlnurHA thanks for your contribution, looks very good! Would be great to add a unit test for this new script, similar to existing tests that we have in tests/metrics/tests-*.sh files. Without a test we simply don't know whether the code works.

@IlnurHA
Copy link
Contributor Author

IlnurHA commented Mar 5, 2024

@yegor256 I created test for hoc metric; please check

@yegor256
Copy link
Owner

yegor256 commented Mar 5, 2024

@IlnurHA looks good now, but this metric is not "hits of code". Instead, we should call it "commits per file" (CPF).

@IlnurHA
Copy link
Contributor Author

IlnurHA commented Mar 5, 2024

@yegor256. I think I explained not in the proper way. Metric increases for a specific class when the class is changed in the commit. Is it not that we are looking for?

@yegor256
Copy link
Owner

yegor256 commented Mar 5, 2024

@IlnurHA "hits of code" metric is explained here: https://www.yegor256.com/2014/11/14/hits-of-code.html It's not a counter of changes. It's a counter of lines added and deleted.

@IlnurHA
Copy link
Contributor Author

IlnurHA commented Mar 25, 2024

@yegor256 I changed calculation of hoc metric and, hopefully, it reflects HOC metric from the source

metrics/hoc.sh Outdated
hoc=0
fi

echo "hoc ${class_name}:${hoc} Hits Of Code for given class" > "${output}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IlnurHA it should print hoc 123 Hits of Code ... (this is how all other metrics print their output, so that it's parseable by steps/measure.sh)

@IlnurHA
Copy link
Contributor Author

IlnurHA commented Mar 26, 2024

@yegor256 I changed the output of HOC script. Hopefully, it meets necessary requirements

@padjal
Copy link
Contributor

padjal commented Apr 22, 2024

@yegor256 This PR is also awaiting approval for the workflows.

@yegor256
Copy link
Owner

@IlnurHA try to merge master branch into this branch -- most probably the tests will pass

@padjal padjal mentioned this pull request Apr 23, 2024
@IlnurHA
Copy link
Contributor Author

IlnurHA commented Apr 24, 2024

@yegor256 I merged. Please check it out

metrics/hoc.sh Outdated
hoc=0
fi

echo "hoc ${hoc} Hits Of Code for ${class_name} class" > "${output}"
Copy link
Owner

Choose a reason for hiding this comment

The 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

metrics/hoc.sh Outdated

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

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

@yegor256
Copy link
Owner

@IlnurHA now it's clean! However, please see two minor comments above

@IlnurHA
Copy link
Contributor Author

IlnurHA commented Apr 25, 2024

@yegor256 I did as you asked. Please check it

@yegor256 yegor256 merged commit 11e61ac into yegor256:master Apr 25, 2024
9 checks passed
@yegor256
Copy link
Owner

@IlnurHA thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hits of Code (HOC) per class
3 participants