diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-12 09:22:53 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-13 09:27:29 -0400 |
commit | f0302d51abf2f4c6d7660b82ad5038d1cbf9e5d7 (patch) | |
tree | 3d5a742fddac7c23a7b6d84dae8bc5966565b35f /scripts | |
parent | ec8c5b3fea78b2596d3b68571fd47b8e41d4a3ea (diff) | |
download | tor-f0302d51abf2f4c6d7660b82ad5038d1cbf9e5d7.tar.gz tor-f0302d51abf2f4c6d7660b82ad5038d1cbf9e5d7.zip |
practracker: Be more careful about excluding "confusing terms"
Previously we excluded any line containing one of these terms from
consideration as the start or end of a function. Now we're more
careful, and we only ignore these terms when they appear to be
starting a function definition.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/maint/practracker/metrics.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py index 56b9e8383e..5fa305a868 100644 --- a/scripts/maint/practracker/metrics.py +++ b/scripts/maint/practracker/metrics.py @@ -25,20 +25,20 @@ def get_function_lines(f): Return iterator which iterates over functions and returns (function name, function lines) """ - # Skip lines with these terms since they confuse our regexp + # Skip lines that look like they are defining functions with these + # names: they aren't real function definitions. REGEXP_CONFUSE_TERMS = {"MOCK_IMPL", "ENABLE_GCC_WARNINGS", "ENABLE_GCC_WARNING", "DUMMY_TYPECHECK_INSTANCE", "DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"} in_function = False for lineno, line in enumerate(f): - if any(x in line for x in REGEXP_CONFUSE_TERMS): - continue - if not in_function: # find the start of a function m = re.match(r'^([a-zA-Z_][a-zA-Z_0-9]*),?\(', line) if m: func_name = m.group(1) + if func_name in REGEXP_CONFUSE_TERMS: + continue func_start = lineno in_function = True |