From a5971d732eac650d3d5eefd63df1cd4e3a9b13f5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 5 Aug 2019 17:35:20 -0400 Subject: [PATCH] Move include-violation checking into its own function. --- scripts/maint/practracker/practracker.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py index 20c8bb5b4e..16ccec3d70 100755 --- a/scripts/maint/practracker/practracker.py +++ b/scripts/maint/practracker/practracker.py @@ -83,6 +83,14 @@ def consider_function_size(fname, f): canonical_function_name = "%s:%s()" % (fname, name) yield problem.FunctionSizeItem(canonical_function_name, lines) +def consider_include_violations(fname, real_fname, f): + n = 0 + for item in includes.consider_include_rules(real_fname, f): + n += 1 + if n: + yield problem.DependencyViolationItem(fname, n) + + ####################################################### def consider_all_metrics(files_list): @@ -119,12 +127,8 @@ def consider_metrics_for_file(fname, f): # Check for "upward" includes f.seek(0) - n = 0 - for item in includes.consider_include_rules(real_fname, f): - n += 1 - if n: - yield problem.DependencyViolationItem(fname, n) - + for item in consider_include_violations(fname, real_fname, f): + yield item HEADER="""\ # Welcome to the exceptions file for Tor's best-practices tracker!