[codeface] [PATCH 15/26] Fix feature analysis

  • From: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Thu, 13 Oct 2016 17:29:47 +0200

This patch fixes following error message: "UnboundLocalError: local
variable 'next_features' referenced before assignment".

The routine was working inside a Vagrant development VM, but not on our
Codeface stand-alone workstation.

Signed-off-by: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
---
 codeface/cluster/cluster.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/codeface/cluster/cluster.py b/codeface/cluster/cluster.py
index f576455..a5844c4 100755
--- a/codeface/cluster/cluster.py
+++ b/codeface/cluster/cluster.py
@@ -333,6 +333,7 @@ def group_feature_lines(file_commit, file_state, cmt_list):
         next_line = lines[0]
         next_cmt_id = file_state[str(next_line)]
         curr_features = file_commit.findFeatureList(curr_line)
+        open_features = []
 
     for i in range(0, len(file_state) - 1):
         curr_line = lines[i]
@@ -362,10 +363,12 @@ def group_feature_lines(file_commit, file_state, 
cmt_list):
                                 curr_cmt_id, feature))
                 blk_start[feature] = next_line
                 blk_end[feature] = next_line
+                # collect features that are still open
+                open_features = next_features
 
     # boundary case for open code-blocks or a single line file_state.
     for feature in feature_blks:
-        if feature in next_features:  # Close all open feature blocks
+        if feature in open_features:  # Close all open feature blocks
             feature_blks[feature].append(
                 codeBlock.codeBlock(
                     blk_start[feature], blk_end[feature],
-- 
2.10.0


Other related posts: