Skip to content

Commit

Permalink
First version of metrics grouping for report generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Raleksan committed Oct 1, 2024
1 parent ab23bb1 commit 2595606
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
8 changes: 4 additions & 4 deletions metrics/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ class NotClassError(Exception):
if not (tree_class := list((value for value in tree))):
raise NotClassError('This is not a class')
with open(metrics, 'a', encoding='utf-8') as metric:
metric.write(f'NoOA {attrs(tree_class)} '
metric.write(f'NoOA {attrs(tree_class)} [CAM]'
f'Number of Non-Static (Object) Attributes\n')
metric.write(f'NoSA {sattrs(tree_class)} '
metric.write(f'NoSA {sattrs(tree_class)} [CAMt]'
f'Number of Static Attributes\n')
metric.write(f'NoCC {ctors(tree_class)} '
metric.write(f'NoCC {ctors(tree_class)} [CAMtt]'
f'Number of Class Constructors\n')
metric.write(f'NoOM {methods(tree_class)} '
metric.write(f'NoOM {methods(tree_class)} [CAMttt]'
f'Number of Non-Static (Object) Methods\n')
metric.write(f'NoCM {smethods(tree_class)} '
f'Number of Static (Class) Methods\n')
Expand Down
35 changes: 34 additions & 1 deletion steps/report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,40 @@ if [ ! -s "${list}" ]; then
exit 1
fi

sort -o "${list}" "${list}"
groups=($(grep -oP '\[.*?\]' "${list}" | sed 's/[][]//g') "")

st_list=${TARGET}/temp/structured-list-of-metrics.tex
rm -f "${st_list}"
touch "${st_list}"

for group in "${groups[@]}"; do

if [[ -z "$group" ]]; then
echo "\item Ungrouped Metrics" >> "${st_list}"
else
echo "\item $group" >> "${st_list}"
fi

echo " \begin{itemize}" >> "${st_list}"

if [[ -z "$group" ]]; then
group_metrics=$(grep -oP "^[^\[]*$" "${list}")
else
group_metrics=$(grep -oP ".*\[\b${group}\b\].*" "${list}")
fi

for metric in "${group_metrics[@]}"; do
printf "\t%s\n" "$metric" >> "${st_list}"
done

echo " \end{itemize}" >> "${st_list}"

done

sed -i 's/\[[^]]*\]//g' "${st_list}"

mv "${st_list}" "${list}"


# It's important to make sure the path is absolute, for LaTeX
t=$(realpath "${TARGET}")
Expand Down

0 comments on commit 2595606

Please sign in to comment.