Refactoring: reduce cyclomatic complexity

This commit is contained in:
Dmitry
2017-09-04 13:41:35 -07:00
parent 13ba9d0f53
commit 97b4f2bba3
2 changed files with 12 additions and 12 deletions
+10 -8
View File
@@ -39,16 +39,18 @@ class Commit(object):
if self._branch_tips:
branch_text = 'Branch tips: {}\n'.format(', '.join(self._branch_tips))
metric_text = ''
if self._is_target and self._target_metric:
metric_text = '\nTarget metric: {}'.format(self._target_metric)
if self._target_metric_delta is not None:
metric_text += ' ({:+f})'.format(self._target_metric_delta)
if self._is_collapsed:
return branch_text + self.COLLAPSED_TEXT + metric_text
return branch_text + self.COLLAPSED_TEXT + self._text_metrics_line()
return branch_text + self._comment[:self.TEXT_LIMIT] + metric_text + '\n' + self.hash
return branch_text + self._comment[:self.TEXT_LIMIT] + self._text_metrics_line() + '\n' + self.hash
def _text_metrics_line(self):
result = ''
if self._is_target and self._target_metric:
result = '\nTarget metric: {}'.format(self._target_metric)
if self._target_metric_delta is not None:
result += ' ({:+f})'.format(self._target_metric_delta)
return result
@property
def is_repro(self):
+2 -4
View File
@@ -31,10 +31,8 @@ class Workflow(object):
if p not in self._edges:
self._edges[p] = set()
self._edges[p].add(commit.hash)
if commit.hash not in self._back_edges:
self._back_edges[commit.hash] = set()
for p in commit.parent_hashes:
if commit.hash not in self._back_edges:
self._back_edges[commit.hash] = set()
self._back_edges[commit.hash].add(p)
if not commit.parent_hashes: