commit ec13a727b0120485d5a90dcd053b3503b3080b58 Author: Nick Mathewson nickm@torproject.org Date: Tue Jul 30 09:03:55 2019 -0400
practracker: Rename "Problem" to "Item".
I'm about to refactor the code into a set of iterators that yield *all* the metrics for the code, and then add a filter on top of that to return the problems. --- scripts/maint/practracker/practracker.py | 6 +++--- scripts/maint/practracker/problem.py | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py index 70035a0ab..bcced93c5 100755 --- a/scripts/maint/practracker/practracker.py +++ b/scripts/maint/practracker/practracker.py @@ -65,7 +65,7 @@ def consider_file_size(fname, f): file_size = metrics.get_file_len(f)
if file_size > MAX_FILE_SIZE: - p = problem.FileSizeProblem(fname, file_size) + p = problem.FileSizeItem(fname, file_size) if ProblemVault.register_problem(p): return 1 return 0 @@ -75,7 +75,7 @@ def consider_includes(fname, f): include_count = metrics.get_include_count(f)
if include_count > MAX_INCLUDE_COUNT: - p = problem.IncludeCountProblem(fname, include_count) + p = problem.IncludeCountItem(fname, include_count) if ProblemVault.register_problem(p): return 1 return 0 @@ -91,7 +91,7 @@ def consider_function_size(fname, f):
# That's a big function! Issue a problem! canonical_function_name = "%s:%s()" % (fname, name) - p = problem.FunctionSizeProblem(canonical_function_name, lines) + p = problem.FunctionSizeItem(canonical_function_name, lines) if ProblemVault.register_problem(p): found_new_issues += 1
diff --git a/scripts/maint/practracker/problem.py b/scripts/maint/practracker/problem.py index 89a8f1234..317e2a4a5 100644 --- a/scripts/maint/practracker/problem.py +++ b/scripts/maint/practracker/problem.py @@ -100,10 +100,10 @@ class ProblemVault(object): if fn is not None: ex.metric_value = fn(ex.metric_value)
-class Problem(object): +class Item(object): """ - A generic problem in our source code. See the subclasses below for the - specific problems we are trying to tackle. + A generic measurement about some aspect of our source code. See + the subclasses below for the specific problems we are trying to tackle. """ def __init__(self, problem_type, problem_location, metric_value): self.problem_location = problem_location @@ -125,7 +125,7 @@ class Problem(object):
def key(self): """Generate a unique key that describes this problem that can be used as a dictionary key""" - # Problem location is a filesystem path, so we need to normalize this + # Item location is a filesystem path, so we need to normalize this # across platforms otherwise same paths are not gonna match. canonical_location = os.path.normcase(self.problem_location) return "%s:%s" % (canonical_location, self.problem_type) @@ -133,7 +133,7 @@ class Problem(object): def __str__(self): return "problem %s %s %s" % (self.problem_type, self.problem_location, self.metric_value)
-class FileSizeProblem(Problem): +class FileSizeItem(Item): """ Denotes a problem with the size of a .c file.
@@ -141,9 +141,9 @@ class FileSizeProblem(Problem): 'metric_value' is the number of lines in the .c file. """ def __init__(self, problem_location, metric_value): - super(FileSizeProblem, self).__init__("file-size", problem_location, metric_value) + super(FileSizeItem, self).__init__("file-size", problem_location, metric_value)
-class IncludeCountProblem(Problem): +class IncludeCountItem(Item): """ Denotes a problem with the number of #includes in a .c file.
@@ -151,9 +151,9 @@ class IncludeCountProblem(Problem): 'metric_value' is the number of #includes in the .c file. """ def __init__(self, problem_location, metric_value): - super(IncludeCountProblem, self).__init__("include-count", problem_location, metric_value) + super(IncludeCountItem, self).__init__("include-count", problem_location, metric_value)
-class FunctionSizeProblem(Problem): +class FunctionSizeItem(Item): """ Denotes a problem with a size of a function in a .c file.
@@ -164,7 +164,7 @@ class FunctionSizeProblem(Problem): The 'metric_value' is the size of the offending function in lines. """ def __init__(self, problem_location, metric_value): - super(FunctionSizeProblem, self).__init__("function-size", problem_location, metric_value) + super(FunctionSizeItem, self).__init__("function-size", problem_location, metric_value)
comment_re = re.compile(r'#.*$')
@@ -182,10 +182,10 @@ def get_old_problem_from_exception_str(exception_str): raise ValueError("Misformatted line {!r}".format(orig_str))
if problem_type == "file-size": - return FileSizeProblem(problem_location, metric_value) + return FileSizeItem(problem_location, metric_value) elif problem_type == "include-count": - return IncludeCountProblem(problem_location, metric_value) + return IncludeCountItem(problem_location, metric_value) elif problem_type == "function-size": - return FunctionSizeProblem(problem_location, metric_value) + return FunctionSizeItem(problem_location, metric_value) else: raise ValueError("Unknown exception type {!r}".format(orig_str))
tor-commits@lists.torproject.org