From a0fce351c48b34748eb97b23db5e33ae27f28122 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 3 May 2024 07:17:24 +0300 Subject: [PATCH 1/5] polish --- tex/report.bib | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tex/report.bib b/tex/report.bib index 9e0ece21..c46f7b55 100644 --- a/tex/report.bib +++ b/tex/report.bib @@ -53,7 +53,6 @@ @misc{fernandez2006 year = {2006}, } - @inproceedings{5463348, author = {Robles, Gregorio}, booktitle = {{Proceedings of the Working Conference on Mining Software Repositories}}, @@ -67,18 +66,18 @@ @article{7887704 author = {Cosentino, Valerio and C\'{a}novas Izquierdo, Javier L. and Cabot, Jordi}, doi = {10.1109/ACCESS.2017.2682323}, journal = {{IEEE Access}}, + number = {1}, pages = {7173--7192}, title = {{A Systematic Mapping Study of Software Development With GitHub}}, volume = {5}, - number = {1}, year = {2017}, } @article{nunez2017source, author = {Nu{\~n}ez-Varela, Alberto S. and P{\'e}rez-Gonzalez, H{\'e}ctor G. and Mart{\'\i}nez-Perez, Francisco E. and Soubervielle-Montalvo, Carlos}, doi = {10.1016/j.jss.2017.03.044}, - number = {1}, journal = {{Journal of Systems and Software}}, + number = {1}, pages = {164--197}, publisher = {Elsevier}, title = {{Source Code Metrics: A Systematic Mapping Study}}, @@ -91,10 +90,10 @@ @article{mccabe1976complexity doi = {10.1109/TSE.1976.233837}, journal = {{IEEE Transactions on Software Engineering}}, number = {4}, - volume = {1}, pages = {308--320}, publisher = {IEEE}, title = {{A Complexity Measure}}, + volume = {1}, year = {1976}, } @@ -109,7 +108,7 @@ @inproceedings{campbell2018cognitive @misc{henderson1996coupling, author = {Henderson-Sellers, Brian and Constantine, Larry L. and Graham, Ian M.}, - publisher = {{Object Oriented Systems}}, + publisher = {Object Oriented Systems}, title = {{Coupling and Cohesion (Towards a Valid Metrics Suite for Object-Oriented Analysis and Design)}}, year = {1996}, } @@ -155,25 +154,25 @@ @misc{daigle2023 } @article{munaiah2017curating, - title={{Curating GitHub for Engineered Software Projects}}, - author={Munaiah, Nuthan and Kroh, Steven and Cabrey, Craig and Nagappan, Meiyappan}, - journal={{Empirical Software Engineering}}, - volume={22}, - number={1}, - pages={3219--3253}, - year={2017}, - publisher={Springer}, - doi={10.1007/s10664-017-9512-6} + author = {Munaiah, Nuthan and Kroh, Steven and Cabrey, Craig and Nagappan, Meiyappan}, + doi = {10.1007/s10664-017-9512-6}, + journal = {{Empirical Software Engineering}}, + number = {1}, + pages = {3219--3253}, + publisher = {Springer}, + title = {{Curating GitHub for Engineered Software Projects}}, + volume = {22}, + year = {2017}, } @article{coleman1994, author = {Coleman, Don and Ash, Dan and Lowther, Bruce and Oman, Paul}, doi = {10.1109/2.303623}, journal = {{Computer}}, - volume={27}, - number={8}, + number = {8}, publisher = {IEEE}, title = {{Using Metrics to Evaluate Software System Maintainability}}, + volume = {27}, year = {1994}, } @@ -184,3 +183,4 @@ @book{halstead1977elements title = {{Elements of Software Science (Operating and Programming Systems Series)}}, year = {1977}, } + From aa510b1d1e5c7fe8e2ae482236971973661f254d Mon Sep 17 00:00:00 2001 From: IlnurHA Date: Fri, 3 May 2024 07:57:38 +0300 Subject: [PATCH 2/5] Relative File Volatility by Hits metric --- metrics/rfvh.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 metrics/rfvh.sh diff --git a/metrics/rfvh.sh b/metrics/rfvh.sh new file mode 100644 index 00000000..96adcdd1 --- /dev/null +++ b/metrics/rfvh.sh @@ -0,0 +1,56 @@ +#!/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") + +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 + my_rvh=$(git log -L:"class\s:${java}" | grep -E "^[+-].*$" | grep -Ev "^\-\-\-\s\S+$" | grep -Evc "^\+\+\+\s\S+$") + files=$(git ls-tree -r "$(git branch --show-current)" --name-only) + all_rvhs=0 + +# source: https://stackoverflow.com/questions/44440506/split-string-with-literal-n-in-a-for-loop + while [[ $files ]]; do # iterate as long as we have input + if [[ $files = *$'\n'* ]]; then # if there's a '\n' sequence later... + first=${files%%$'\n'*} # put everything before it into 'first' + rest=${files#*$'\n'} # and put everything after it in 'rest' + else # if there's no '\n' later... + first=${files} # then put the whole rest of the string in 'first' + rest='' # and there is no 'rest' + fi + rvh=$(git log -L:"class\s:${first}" | grep -E "^[+-].*$" | grep -Ev "^\-\-\-\s\S+$" | grep -Evc "^\+\+\+\s\S+$") + ((all_rvhs+=rvh)) + files=$rest + done + rfvh=$(python3 -c "print(${my_rvh} / ${all_rvhs})") +else + rfvh=0 +fi + +echo "rfvh ${rfvh} Relative File Volatility by Hits for file" > "${output}" \ No newline at end of file From 5d1435199af35a41ea9fbb8496c164f17583b4a3 Mon Sep 17 00:00:00 2001 From: IlnurHA Date: Fri, 3 May 2024 08:01:49 +0300 Subject: [PATCH 3/5] Test for rfvh --- tests/metrics/test-rfvh.sh | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/metrics/test-rfvh.sh diff --git a/tests/metrics/test-rfvh.sh b/tests/metrics/test-rfvh.sh new file mode 100644 index 00000000..aad6e25f --- /dev/null +++ b/tests/metrics/test-rfvh.sh @@ -0,0 +1,70 @@ +#!/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 + +{ + metric_script_path="${LOCAL}/metrics/rfvh.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/" + java1="FooTest.java" + java2="FooTest2.java" + java3="FooTest3.java" + + mkdir -p "${java_dir}" + cd ${java_dir} + + touch "${java1}" + touch "stdout" + + printf "class Foo {}" > "${java1}" + git add "${java1}" + git commit --quiet -m "first commit" + ${metric_script_path} "${java1}" "stdout" + grep "rfvh 1" "stdout" + + printf "class Foo {}" > "${java2}" + git add "${java2}" + git commit --quiet -m "+second commit" + ${metric_script_path} "${java1}" "stdout" + grep "rfvh 0.5" "stdout" + + printf "class Foo {}" > "${java3}" + git add "${java3}" + git commit --quiet -m "-third commit" + ${metric_script_path} "${java1}" "stdout" + grep "rfvh 0.33" "stdout" +} > "${stdout}" 2>&1 +echo "👍🏻 Correctly calculated relative file volatility by hits" \ No newline at end of file From d46ce0a0c469c470ce4ce852a0fb7bcfd6f3c6dc Mon Sep 17 00:00:00 2001 From: IlnurHA Date: Fri, 3 May 2024 08:02:51 +0300 Subject: [PATCH 4/5] Add pipefail --- metrics/rfvh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/rfvh.sh b/metrics/rfvh.sh index 96adcdd1..3b2ca6e6 100644 --- a/metrics/rfvh.sh +++ b/metrics/rfvh.sh @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. set -e -#set -o pipefail +set -o pipefail java=$1 output=$(realpath "$2") From 306f48d41037bfde48f0ec8e17245b60b9cbce3e Mon Sep 17 00:00:00 2001 From: IlnurHA Date: Fri, 3 May 2024 08:07:07 +0300 Subject: [PATCH 5/5] Change for test and metric to be executable --- metrics/rfvh.sh | 0 tests/metrics/test-rfvh.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 metrics/rfvh.sh mode change 100644 => 100755 tests/metrics/test-rfvh.sh diff --git a/metrics/rfvh.sh b/metrics/rfvh.sh old mode 100644 new mode 100755 diff --git a/tests/metrics/test-rfvh.sh b/tests/metrics/test-rfvh.sh old mode 100644 new mode 100755