summaryrefslogtreecommitdiff
path: root/scripts/maint/practracker/metrics.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-07-17 14:00:28 +0200
committerNick Mathewson <nickm@torproject.org>2019-07-17 14:33:49 +0200
commit4c095329964c47c7a37c812fdaf58b9238cc9ff5 (patch)
treee2816d1d95e98b31cae14fe686ef76c42e274f60 /scripts/maint/practracker/metrics.py
parent5303dbe6249ed4b1e268f7a5c41ed6a638c4d0e3 (diff)
downloadtor-4c095329964c47c7a37c812fdaf58b9238cc9ff5.tar.gz
tor-4c095329964c47c7a37c812fdaf58b9238cc9ff5.zip
Fix practracker_tests.py and practracker line counting.
The practracker_tests.py unit test file called a function by its old name. Also, practracker counted functions as starting one line after the function name, and ending with the closing brace. Now they start with the open brace and end with the closing brace.
Diffstat (limited to 'scripts/maint/practracker/metrics.py')
-rw-r--r--scripts/maint/practracker/metrics.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py
index 5fa305a868..b35029b51d 100644
--- a/scripts/maint/practracker/metrics.py
+++ b/scripts/maint/practracker/metrics.py
@@ -31,6 +31,7 @@ def get_function_lines(f):
"DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"}
in_function = False
+ found_openbrace = False
for lineno, line in enumerate(f):
if not in_function:
# find the start of a function
@@ -41,10 +42,13 @@ def get_function_lines(f):
continue
func_start = lineno
in_function = True
-
+ elif not found_openbrace and line.startswith("{"):
+ found_openbrace = True
+ func_start = lineno
else:
# Find the end of a function
if line.startswith("}"):
- n_lines = lineno - func_start
+ n_lines = lineno - func_start + 1
in_function = False
+ found_openbrace = False
yield (func_name, n_lines)