From 83f743f0b81a0cb50f019cb66b1a4d81bd4fb863 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Sat, 18 May 2024 18:03:59 +0300 Subject: [PATCH] refactored the NOMR calculation method --- metrics/ast.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/metrics/ast.py b/metrics/ast.py index 83590846..8ef44c1f 100755 --- a/metrics/ast.py +++ b/metrics/ast.py @@ -163,7 +163,12 @@ def nomr(tlist: list[tuple[Any, javalang.tree.ClassDeclaration]]) -> float: :rtype: float """ total_methods_number = total_methods(tlist) - return nom(tlist) / total_methods_number if total_methods_number != 0 else 0 + if total_methods_number == 0: + return 0 + nom_result = nom(tlist) + if nom_result == 0: + return 0 + return nom_result / total_methods_number def attrs(tlist: list[tuple[Any, javalang.tree.ClassDeclaration]]) -> int: