|
@@ -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))
|