Skip to content

Commit

Permalink
float
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 22, 2025
1 parent 2177227 commit 2cc587f
Show file tree
Hide file tree
Showing 49 changed files with 49 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ test-zone/
pylint_plugins/__pycache__
target/
predictions.csv

install-tl.log
install-tl.zip.*
install-tl/
venv/
pipeline/
2 changes: 1 addition & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
disable=SC2030,SC2031
disable=SC2030,SC2031
3 changes: 2 additions & 1 deletion DEPENDS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hard environ
hard everyshi
hard fdsymbol
hard ffcode
hard float
hard fmtcount
hard footmisc
hard framed
Expand Down Expand Up @@ -56,4 +57,4 @@ hard transparent
hard trimspaces
hard upquote
hard wrapfig
hard xstring
hard xstring
1 change: 0 additions & 1 deletion filters/080-delete-symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ if [ "${total}" -eq 0 ]; then
else
printf "%'d symlinks were deleted" "${total}"
fi

1 change: 0 additions & 1 deletion filters/090-delete-empty-directories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ if [ "${total}" -eq 0 ]; then
else
printf "%'d empty directories were deleted" "${total}"
fi

2 changes: 1 addition & 1 deletion fixtures/filters/unparseable/ParseDouble.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ public static void main(String[] args)
System.out.println(pDouble.call(new Object[]
{ "abcd" }, ctx));
}
}
}
2 changes: 1 addition & 1 deletion fixtures/filters/unparseable/PlotPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1098,4 +1098,4 @@ public interface PlotPlayerConverter<BaseObject> {

}

}
}
2 changes: 1 addition & 1 deletion fixtures/filters/unparseable/UUIDPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,4 @@ final UUIDMapping getImmediately(final @NonNull Object object) {
return null;
}

}
}
2 changes: 1 addition & 1 deletion help/float.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set -o pipefail
num=$(cat)

if [[ -z "${num}" || "${num}" =~ ^[[:space:]]+$ ]]; then
echo "0.000"
echo "0.000"
exit
fi

Expand Down
2 changes: 1 addition & 1 deletion help/gnu-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ date() {
command date "$@"
fi
}
export -f date
export -f date
2 changes: 1 addition & 1 deletion help/is-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
exit 0
else
exit 1
fi
fi
2 changes: 1 addition & 1 deletion help/parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ args=(
"--max-procs=${cores}"
"--will-cite"
)
uniq "${jobs}" | parallel "${args[@]}"
uniq "${jobs}" | parallel "${args[@]}"
2 changes: 1 addition & 1 deletion help/sudo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ if "${LOCAL}/help/is-linux.sh" || "${LOCAL}/help/is-macos.sh" ; then
fi
else
sudo "$@"
fi
fi
2 changes: 1 addition & 1 deletion help/to-csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ set -o pipefail
# suitable for CSV: replacing commas.

data=$(cat)
printf '%s' "${data}" | sed 's/,/\\,/g'
printf '%s' "${data}" | sed 's/,/\\,/g'
2 changes: 1 addition & 1 deletion metrics/bug_discover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EOT
cp "${java}" "${tmp}/foo.java"

export PMD_JAVA_OPTS=${JVM_OPTS}
# We don't use --cache here, because it becomes too big and leads to "Out Of Memory" error
# We don't use --cache here, because it becomes too big and leads to "Out Of Memory" error
pmd check -R "${tmp}/config.xml" -d "${tmp}" --format xml --no-fail-on-error --no-fail-on-violation > "${tmp}/result.xml" 2> "${tmp}/stderr.txt" || (cat "${tmp}/stderr.txt"; exit 1)

violation_num=$(awk '/<violation/ {count++} END {print count+0}' "${tmp}/result.xml")
Expand Down
1 change: 0 additions & 1 deletion metrics/ir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ set -o pipefail
output=$(realpath "$2")

echo "IR 0.000 " >"${output}"

2 changes: 1 addition & 1 deletion metrics/irc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ set -o pipefail

output=$(realpath "$2")

echo "IRC 0.000 " >"${output}"
echo "IRC 0.000 " >"${output}"
2 changes: 1 addition & 1 deletion metrics/irloc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ set -o pipefail

output=$(realpath "$2")

echo "IRLoC 0.000 " >"${output}"
echo "IRLoC 0.000 " >"${output}"
2 changes: 1 addition & 1 deletion metrics/multimetric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ HSE $(echo "${body}" | jq '.halstead_effort' | "${LOCAL}/help/float.sh") \textbf
HSV $(echo "${body}" | jq '.halstead_volume' | "${LOCAL}/help/float.sh") \textbf{Halstead Volume}: This metric measures the size of a program based on its operators and operands. Halstead Volume estimates the amount of mental effort required to understand the code. It is calculated as \( \text{Volume} = (n_1 + n_2) \times \log_2 (n_1 + n_2) \), where \( n_1 \) and \( n_2 \) are the number of distinct operators and operands, respectively. A larger volume indicates a larger and potentially more complex program. See details: \href{https://en.wikipedia.org/wiki/Halstead_complexity_measures#Volume}{Halstead Volume on Wikipedia}
MIdx $(echo "${body}" | jq '.maintainability_index' | "${LOCAL}/help/float.sh") \textbf{Maintainability Index}: This metric is used to assess the maintainability of a software system based on its complexity and readability. It is a composite measure that takes into account various code metrics such as lines of code, cyclomatic complexity, and Halstead volume. The higher the Maintainability Index, the more maintainable the code is considered to be. The index is typically calculated using the formula:
FOut $(echo "${body}" | jq '.fanout_external' | "${LOCAL}/help/float.sh") \textbf{Fan-Out}: This metric measures the extent to which a class or module depends on external components or other classes. A higher Fan-Out indicates that the class has a greater number of dependencies, which can lead to increased complexity and potential difficulties in maintaining the system. See details: \href{https://en.wikipedia.org/wiki/Fan-out_(software)}{Fan-Out on Wikipedia}
EOT
EOT
1 change: 0 additions & 1 deletion metrics/pmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ sed 's/xmlns=".*"//g' "${tmp}/result.xml" | \
" > "${output}"

rm -rf "${tmp}"

2 changes: 1 addition & 1 deletion metrics/rfvh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ else
rfvh=0
fi

echo "RFVH ${rfvh} Relative File Volatility by Hits for file" > "${output}"
echo "RFVH ${rfvh} Relative File Volatility by Hits for file" > "${output}"
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ ignore_missing_imports = True
; metrics/ast.py:28: error: Skipping analyzing "javalang": module is installed, but missing library stubs or py.typed marker [import-untyped]

; If we generate stubs for "javalang", we will get .pyi that are not always typed. "mypy" will not allow this.
; In order to fix it, we should rewrite "javalang" module. However, this is the third-party library.
; In order to fix it, we should rewrite "javalang" module. However, this is the third-party library.
4 changes: 2 additions & 2 deletions steps/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if [[ -z "$FORCE_INSTALL" ]]; then
done

read -p "Do you want to proceed with the installation? (y/n): " -n 1 -r
echo
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Installation aborted by user."
exit 1
Expand All @@ -90,7 +90,7 @@ function install_package() {
elif "${LOCAL}/help/is-macos.sh"; then
if brew -v; then
"${LOCAL}/help/sudo.sh" --as-user brew install "$PACKAGE"
else
else
echo "If you install Homebrew, all necessary packages will be installed automatically by running 'make install'. Visit the Homebrew installation documentation at: https://docs.brew.sh/Installation"
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions steps/jpeek-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ build() {
echo "Building ${repo} (${pos}/${total}) with Gradle..."
echo "apply plugin: 'java'" >> "${project}/build.gradle"
if ! timeout 1h gradle classes -q -p "${project}" > "${logs}/gradle.log" 2>&1; then
echo "Failed to compile ${repo} using Gradle$("${LOCAL}/help/tdiff.sh" "${start}")"
echo "Failed to compile ${repo} using Gradle$("${LOCAL}/help/tdiff.sh" "${start}")"
echo "Failure ${repo} Gradle" >> "${failure_log}"
exit
fi
Expand Down Expand Up @@ -131,7 +131,7 @@ for type in all cvc; do
if [ ! "${type}" = "all" ]; then
suffix=${suffix}-${type}
fi

jfile=$(find "${project}" -type f -path "*${package}/${class}.java" -exec bash -c 'realpath --relative-to="${1}" "$2"' _ "${project}" {} \;)
echo "${jfile}" >> "${files}"
mfile=${TARGET}/measurements/${repo}/${jfile}.m.${suffix}
Expand Down
2 changes: 1 addition & 1 deletion steps/polish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
olist=${TARGET}/temp/orgs-to-polish.txt
mkdir -p "$(dirname "${olist}")"
echo "Wait a bit, searching for orgs in '${dir}'..."

find "${dir}" -maxdepth 1 -mindepth 1 -type d -exec bash -c 'realpath --relative-to="${1}" "$2"' _ "${dir}" {} \; > "${olist}"

if [ -s "${olist}" ]; then
Expand Down
1 change: 0 additions & 1 deletion steps/unregister.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ while IFS=',' read -r r tag tail; do
fi
done < "${before}"
echo "All ${total} repositories checked, ${good} are good"

1 change: 0 additions & 1 deletion steps/zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ echo "Lines in repositories.csv: $(wc -l "${TARGET}/repositories.csv" | xargs)"
echo ".java files in github/: $(find "${TARGET}/github" -name '*.java' -type f -print | wc -l | xargs)"
echo "Lines in data/all.csv: $(wc -l "${TARGET}/data/all.csv" | xargs)"
echo ".csv files in data/: $(find "${TARGET}/data" -name '*.csv' -type f -print | wc -l | xargs)"

1 change: 0 additions & 1 deletion tests/filters/test-010-delete-non-java-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ echo "👍🏻 An empty directory didn't crash it"
test "$(wc -l < "${list}" | xargs)" = 1
} > "${stdout}" 2>&1
echo "👍🏻 A binary non-Java file was deleted"

1 change: 0 additions & 1 deletion tests/filters/test-020-delete-package-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ stdout=$2
test "$(wc -l < "${list}" | xargs)" = 1
} > "${stdout}" 2>&1
echo "👍🏻 A package-info.java file was deleted"

1 change: 0 additions & 1 deletion tests/filters/test-021-delete-module-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ stdout=$2
test "$(wc -l < "${list}" | xargs)" = 1
} > "${stdout}" 2>&1
echo "👍🏻 A module-info.java file was deleted"

1 change: 0 additions & 1 deletion tests/filters/test-030-delete-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ stdout=$2
test "$(wc -l < "${list}" | xargs)" = 1
} > "${stdout}" 2>&1
echo "👍🏻 A Java test file was deleted"

2 changes: 1 addition & 1 deletion tests/filters/test-040-delete-unparseable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ echo "👍🏻 An unparseable Java file was deleted"
grep "Usage: python delete-unparseable.py <path to the .java file> <output file with .java files>" "${temp}/message"
fi
} > "${stdout}" 2>&1
echo "👍🏻 Usage works correctly"
echo "👍🏻 Usage works correctly"
1 change: 0 additions & 1 deletion tests/filters/test-050-delete-long-lines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ echo "👍🏻 A non-unicode file didn't cause awk troubles"
test "$(wc -l < "${list}" | xargs)" = 0
} > "${stdout}" 2>&1
echo "👍🏻 An empty Java file wasn't deleted"

1 change: 0 additions & 1 deletion tests/filters/test-delete-non-classes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ echo "👍🏻 Absent file didn't fail the script"
grep -v "${java}" "${temp}/deleted.txt"
} > "${stdout}" 2>&1
echo "👍🏻 A good Java file was not deleted, it's correct behavior"

2 changes: 1 addition & 1 deletion tests/filters/test-delete-wrong-encoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ echo "👍🏻 A Java file with a UTF-8 encoding was not deleted"
grep "Usage: python delete-wrong-encoding.py <path to the .java file> <output file with .java files>" "${temp}/message"
fi
} > "${stdout}" 2>&1
echo "👍🏻 Usage works correctly"
echo "👍🏻 Usage works correctly"
2 changes: 1 addition & 1 deletion tests/metrics/test-ast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ echo "👍🏻 Usage works correctly"
grep "NOM 1 " "${temp}/stdout"
grep "NOMR 0.5 " "${temp}/stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly calculated NOM and NOMR"
echo "👍🏻 Correctly calculated NOM and NOMR"
12 changes: 6 additions & 6 deletions tests/metrics/test-getset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ script_location="${LOCAL}/metrics/getset.py"
echo "public class Person {
private String name;
private int age;
public String getName() {return this.name;}
public void setName(String name) {this.name = name;}
public int getAge() {return this.age;}
public void setAge(int age) {this.age = age;}
public void setName(String name) {this.name = name;}
public int getAge() {return this.age;}
public void setAge(int age) {this.age = age;}
public void nonAccessorMethod() {
if (age > 18) {System.out.println(\"Adult\");}
}
}" > "${java_file}"

metrics_file="${temp}/metrics.txt"
"${script_location}" "${java_file}" "${metrics_file}"
cat "${metrics_file}"

# Assertions: Check for expected output related to getter, setter, and branches
grep "Getters 2 The number of getter methods" "${metrics_file}"
grep "Setters 2 The number of setter methods" "${metrics_file}"
Expand Down
8 changes: 4 additions & 4 deletions tests/metrics/test-rfvc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ stdout=$2

${metric_script_path} "${java1}" "stdout"
grep "RFVC 0.33" "stdout"

${metric_script_path} "${java2}" "stdout"
grep "RFVC 0.33" "stdout"

Expand All @@ -83,13 +83,13 @@ stdout=$2
printf "class Foo2 {}" > "${java1}"
git add "${java1}"
git commit --quiet -m "forth commit"

${metric_script_path} "${java1}" "stdout"
grep "RFVC 0.5" "stdout"

${metric_script_path} "${java2}" "stdout"
grep "RFVC 0.25" "stdout"

${metric_script_path} "${java3}" "stdout"
grep "RFVC 0.25" "stdout"

Expand Down
2 changes: 1 addition & 1 deletion tests/metrics/test-rfvh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ stdout=$2
${metric_script_path} "${java1}" "stdout"
grep "RFVH 0.33" "stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly calculated relative file volatility by hits"
echo "👍🏻 Correctly calculated relative file volatility by hits"
2 changes: 1 addition & 1 deletion tests/steps/test-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ temp=$1
stdout=$2

uri=${temp}/foo!
git init --quiet --initial-branch=master "${uri}"
git init --quiet --initial-branch=master "${uri}"
cd "${uri}"
git config user.email '[email protected]'
git config user.name 'Foo'
Expand Down
3 changes: 1 addition & 2 deletions tests/steps/test-measure-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ EOT
StdOut.println("|a| = " + a.abs());
StdOut.println("tan(a) = " + a.tan());
}
}
}
EOT
msg=$("${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m4")
all=$(find "${temp}" -name 'm4.*' -type f -exec basename {} \; | sort)
Expand All @@ -261,4 +261,3 @@ EOT
fi
} > "${stdout}" 2>&1
echo "👍🏻 Number of metrics matches for simple and complex Java files: ${actual_number_of_metrics_simple} metrics"

2 changes: 1 addition & 1 deletion tests/steps/test-measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ EOT
metrics=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \; | sort)
echo -n "${metrics}" | while IFS= read -r m; do
name=${m:3:100}

echo "Checking ${name}..."
if echo "${name}" | grep -q -E '(.)*(Mn|Mx|Av)(.)+'; then
echo "Error: ${name} is not correctly formatted."
Expand Down
2 changes: 1 addition & 1 deletion tests/steps/test-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ echo "👍🏻 A list of metrics is properly formatted"
}
' <<< "$txt"
} > "${stdout}" 2>&1
echo "👍🏻 Grouping is properly formatted for the list of metrics."
echo "👍🏻 Grouping is properly formatted for the list of metrics."
2 changes: 1 addition & 1 deletion tex/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ _minted-*
*.aux
*.pyg
*.out
*.synctex.gz
*.synctex.gz
2 changes: 1 addition & 1 deletion tex/.texqc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--ignore=You have called
--ignore=You have called
1 change: 0 additions & 1 deletion tex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ zip: *.tex

clean:
git clean -dfX

2 changes: 1 addition & 1 deletion tex/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Bugayenko
yegor
github
repo
printf
printf
1 change: 0 additions & 1 deletion tex/report.bib
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,3 @@ @book{halstead1977elements
title = {{Elements of Software Science (Operating and Programming Systems Series)}},
year = {1977},
}

Loading

0 comments on commit 2cc587f

Please sign in to comment.