Skip to content

Commit

Permalink
metrics renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 21, 2023
1 parent a9b0026 commit da571b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
32 changes: 16 additions & 16 deletions metrics/ast.py
Expand Up @@ -160,28 +160,28 @@ 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'attrs {attrs(tree_class)} '
f'Number of Non-Static Attributes\n')
metric.write(f'sattrs {sattrs(tree_class)} '
metric.write(f'nooa {attrs(tree_class)} '
f'Number of Non-Static (Object) Attributes\n')
metric.write(f'nosa {sattrs(tree_class)} '
f'Number of Static Attributes\n')
metric.write(f'ctors {ctors(tree_class)} '
f'Number of Constructors\n')
metric.write(f'mtds {methods(tree_class)} '
f'Number of Non-Static Methods\n')
metric.write(f'smtds {smethods(tree_class)} '
f'Number of Static Methods\n')
metric.write(f'nocc {ctors(tree_class)} '
f'Number of Class Constructors\n')
metric.write(f'noom {methods(tree_class)} '
f'Number of Non-Static (Object) Methods\n')
metric.write(f'nocm {smethods(tree_class)} '
f'Number of Static (Class) Methods\n')
metric.write(f'ncss {ncss(raw)} '
f'Non-Commenting Source Statements (NCSS)\n')
metric.write(f'impls {impls(tree_class)} '
metric.write(f'noii {impls(tree_class)} '
f'Number of Implemented Interfaces\n')
metric.write(f'extnds {extnds(tree_class)} '
f'Number of Extended Classes\n')
metric.write(f'gnrcs {gnrcs(tree_class)} '
f'Number of Type Parameters (generics)\n')
metric.write(f'napc {extnds(tree_class)} '
f'Number of Ancestor (Parent) Classes\n')
metric.write(f'notp {gnrcs(tree_class)} '
f'Number of Type Parameters (Generics)\n')
metric.write(f'final {final(tree_class)} '
f'Class is Final\n')
metric.write(f'annts {annts(tree_class)} '
f'Number of Annotations\n')
metric.write(f'noca {annts(tree_class)} '
f'Number of Class Annotations\n')
except FileNotFoundError as exception:
message = f"{type(exception).__name__} {str(exception)}: {JAVA}"
sys.exit(message)
14 changes: 7 additions & 7 deletions tests/metrics/test-ast.sh
Expand Up @@ -35,13 +35,13 @@ stdout=$2
int y() { return 0; }
}" > "${java}"
"${LOCAL}/metrics/ast.py" "${java}" "${temp}/stdout"
grep "attrs 1" "${temp}/stdout"
grep "sattrs 1" "${temp}/stdout"
grep "mtds 2" "${temp}/stdout"
grep "impls 2" "${temp}/stdout"
grep "extnds 1" "${temp}/stdout"
grep "gnrcs 1" "${temp}/stdout"
grep "nooa 1" "${temp}/stdout"
grep "noca 1" "${temp}/stdout"
grep "noom 2" "${temp}/stdout"
grep "noii 2" "${temp}/stdout"
grep "napc 1" "${temp}/stdout"
grep "notp 1" "${temp}/stdout"
grep "final 1" "${temp}/stdout"
grep "annts 1" "${temp}/stdout"
grep "noca 1" "${temp}/stdout"
} > "${stdout}" 2>&1
echo "👍🏻 Correctly collected AST metrics"
11 changes: 6 additions & 5 deletions tests/steps/test-measure-file.sh
Expand Up @@ -44,15 +44,16 @@ EOT
set -x
echo "${msg}"
test "$(echo "${msg}" | grep -c "sum=0")" = 0
test "$(find "${temp}" -name 'm.*' -type f | wc -l | xargs)" = "34"
test "$(cat "${temp}/m.loc")" = "8"
test "$(cat "${temp}/m.comments")" = "1"
test "$(cat "${temp}/m.cc")" = "1"
test "$(cat "${temp}/m.ncss")" = "7"
test "$(cat "${temp}/m.smtds")" = "0"
test "$(cat "${temp}/m.mtds")" = "1"
test "$(cat "${temp}/m.ctors")" = "1"
test "$(cat "${temp}/m.extnds")" = "1"
test "$(cat "${temp}/m.impls")" = "1"
test "$(cat "${temp}/m.nocm")" = "0"
test "$(cat "${temp}/m.noom")" = "1"
test "$(cat "${temp}/m.nocc")" = "1"
test "$(cat "${temp}/m.napc")" = "1"
test "$(cat "${temp}/m.noii")" = "1"
test "$(cat "${temp}/m.final")" = "0"
test "$(cat "${temp}/m.blanks")" = "1"
set +x
Expand Down

0 comments on commit da571b0

Please sign in to comment.