From 7d7ae494d476f2e0588740612846da4284b3da0c Mon Sep 17 00:00:00 2001
From: Gabriel Gizotti <gabriel@gizotti.com>
Date: Mon, 5 Dec 2016 21:44:29 +1000
Subject: [PATCH] add guard clause to
 MergeRequest#issues_mentioned_but_not_closing

---
 app/models/merge_request.rb | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index da293c3738..acaf14a12e 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -569,17 +569,14 @@ class MergeRequest < ActiveRecord::Base
   end
 
   def issues_mentioned_but_not_closing(current_user = self.author)
-    issues = []
-    closing_issues = []
+    return [] unless target_branch == project.default_branch
 
-    if target_branch == project.default_branch
-      ext = Gitlab::ReferenceExtractor.new(project, current_user)
-      ext.analyze(description)
+    ext = Gitlab::ReferenceExtractor.new(project, current_user)
+    ext.analyze(description)
 
-      issues = ext.issues
-      closing_issues = Gitlab::ClosingIssueExtractor.new(project, current_user).
-        closed_by_message(description)
-    end
+    issues = ext.issues
+    closing_issues = Gitlab::ClosingIssueExtractor.new(project, current_user).
+      closed_by_message(description)
 
     issues - closing_issues
   end
-- 
2.30.9