From d5b59df492fc9b5f7aaa4338dce629e8cc23e0c8 Mon Sep 17 00:00:00 2001 From: dzhovi Date: Thu, 28 Nov 2024 10:17:45 +0300 Subject: [PATCH] syntax fixes --- metrics/ast.py | 11 ++++++++--- metrics/multimetric.sh | 12 ++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/metrics/ast.py b/metrics/ast.py index 8312991d..4c21f54c 100755 --- a/metrics/ast.py +++ b/metrics/ast.py @@ -468,7 +468,9 @@ class NotClassError(Exception): 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') + f'Non-Commenting Source Statements (NCSS). This metric that measures the number of lines' + f'in source code that are not comments or blank lines. It focuses on the actual executable' + f'statements in the code, excluding any documentation or formatting lines.\n') metric.write(f'NoII {impls(tree_class)} ' f'Number of Implemented Interfaces\n') metric.write(f'NAPC {extnds(tree_class)} ' @@ -522,9 +524,12 @@ class NotClassError(Exception): f'Number of Polymorphic Methods (NOP), which is the count of methods \ that are overloaded at least once --- have similar names but different parameters\n') metric.write(f'NULLs {nulls(tree_class)} ' - f'Number of NULL References\n') + f'Number of references that are NULL by default in a given class \n') metric.write(f'DOER {doer(tree_class)} ' - f'Data vs Object Encapsulation Ratio\n') + f'Data vs Object Encapsulation Ratio (DOER). This metric represents the ratio of' + f'attributes that store primitive data types (e.g., int, char, boolean) to the total' + f'number of attributes in a class. It provides insight into the balance between simple' + f'data storage (primitives) and references to more complex objects (references).\n') except FileNotFoundError as exception: message = f"{type(exception).__name__} {str(exception)}: {java}" sys.exit(message) diff --git a/metrics/multimetric.sh b/metrics/multimetric.sh index 9220642e..f1f77f4d 100755 --- a/metrics/multimetric.sh +++ b/metrics/multimetric.sh @@ -33,9 +33,9 @@ temp="${TARGET}/temp/multimetric.json" mkdir -p "$(dirname "${temp}")" echo "${body}" > "${temp}" cat < "${output}" -HSD $(echo "${body}" | jq '.halstead_difficulty' | "${LOCAL}/help/float.sh") Halstead Difficulty~\citep{halstead1977elements} -HSE $(echo "${body}" | jq '.halstead_effort' | "${LOCAL}/help/float.sh") Halstead Effort~\citep{halstead1977elements} -HSV $(echo "${body}" | jq '.halstead_volume' | "${LOCAL}/help/float.sh") Halstead Volume~\citep{halstead1977elements} -MIdx $(echo "${body}" | jq '.maintainability_index' | "${LOCAL}/help/float.sh") Maintainability Index~\citep{coleman1994} -FOut $(echo "${body}" | jq '.fanout_external' | "${LOCAL}/help/float.sh") \href{https://en.wikipedia.org/wiki/Fan-out_(software)}{Fan-Out} -EOT +HSD $(echo "${body}" | jq '.halstead_difficulty' | "${LOCAL}/help/float.sh") \textbf{Halstead Difficulty}: This metric measures the difficulty of understanding a program based on the number of distinct operators and operands used. A higher Halstead Difficulty indicates that the program is harder to understand and maintain due to its complexity. It is calculated using the formula: \( \text{Difficulty} = \frac{(n_1)}{2} \times \frac{(n_2)}{n_2} \), where \( n_1 \) is the number of distinct operators, and \( n_2 \) is the number of distinct operands. See details: \href{https://en.wikipedia.org/wiki/Halstead_complexity_measures#Difficulty}{Halstead Difficulty on Wikipedia} +HSE $(echo "${body}" | jq '.halstead_effort' | "${LOCAL}/help/float.sh") \textbf{Halstead Effort}: This metric estimates the total effort required to understand and implement a program based on its size and complexity. The higher the effort, the more difficult the program is to maintain and modify. Halstead Effort is calculated as \( \text{Effort} = \text{Difficulty} \times \text{Volume} \), where Difficulty is the Halstead Difficulty, and Volume represents the size of the program. A higher value reflects more effort required for comprehension and modification. See details: \href{https://en.wikipedia.org/wiki/Halstead_complexity_measures#Effort}{Halstead Effort on Wikipedia} +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 \ No newline at end of file