summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-08 16:34:53 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-08 16:34:53 +0000
commit989a9607e6bf63888b8856eb58a1c8e3e65e3604 (patch)
treecf77897da1e2283f74e178b373c69e2098c3a0b3
parent140a706e96220ef1dab9ba220d86531ca5d46058 (diff)
parent4c388fb86500a2691c7b584ffafcbac18d643cab (diff)
downloadgitlab-ce-989a9607e6bf63888b8856eb58a1c8e3e65e3604.tar.gz
Merge branch 'rubocop/enable-identical-conditional-branches-cop' into 'master'
Enable Style/IdenticalConditionalBranches Rubocop cop ## What does this MR do? This MR enables Rubocop cop that checks for identical lines at the end of each branch of a conditional statement. Examples: ```ruby @bad if condition do_x do_z else do_y do_z end @good if condition do_x else do_y end do_z ``` ## What are the relevant issue numbers? #17478 See merge request !5011
-rw-r--r--.rubocop.yml2
-rw-r--r--app/controllers/projects_controller.rb4
-rw-r--r--app/models/project_services/irker_service.rb10
-rw-r--r--app/services/merge_requests/refresh_service.rb11
-rw-r--r--lib/rouge/formatters/html_gitlab.rb16
5 files changed, 13 insertions, 30 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index cd13f581517..3aac8401848 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -284,7 +284,7 @@ Style/IfWithSemicolon:
# Checks that conditional statements do not have an identical line at the
# end of each branch, which can validly be moved out of the conditional.
Style/IdenticalConditionalBranches:
- Enabled: false
+ Enabled: true
# Checks the indentation of the first line of the right-hand-side of a
# multi-line assignment.
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 12e0d5a8413..1803aa8eab4 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -53,11 +53,11 @@ class ProjectsController < Projects::ApplicationController
notice: "Project '#{@project.name}' was successfully updated."
)
end
- format.js
else
format.html { render 'edit' }
- format.js
end
+
+ format.js
end
end
diff --git a/app/models/project_services/irker_service.rb b/app/models/project_services/irker_service.rb
index 58cb720c3c1..ce7d1c5d5b1 100644
--- a/app/models/project_services/irker_service.rb
+++ b/app/models/project_services/irker_service.rb
@@ -112,15 +112,7 @@ class IrkerService < Service
# Authorize both irc://domain.com/#chan and irc://domain.com/chan
if uri.is_a?(URI) && uri.scheme[/^ircs?\z/] && !uri.path.nil?
- # Do not authorize irc://domain.com/
- if uri.fragment.nil? && uri.path.length > 1
- uri.to_s
- else
- # Authorize irc://domain.com/smthg#chan
- # The irker daemon will deal with it by concatenating smthg and
- # chan, thus sending messages on #smthgchan
- uri.to_s
- end
+ uri.to_s
end
end
end
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index 21490ac77ea..b11ecd97a57 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -61,19 +61,14 @@ module MergeRequests
merge_requests.each do |merge_request|
if merge_request.source_branch == @branch_name || force_push?
merge_request.reload_diff
- merge_request.mark_as_unchecked
else
mr_commit_ids = merge_request.commits.map(&:id)
push_commit_ids = @commits.map(&:id)
matches = mr_commit_ids & push_commit_ids
-
- if matches.any?
- merge_request.reload_diff
- merge_request.mark_as_unchecked
- else
- merge_request.mark_as_unchecked
- end
+ merge_request.reload_diff if matches.any?
end
+
+ merge_request.mark_as_unchecked
end
end
diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb
index 8c309efc7b8..3358ed6773e 100644
--- a/lib/rouge/formatters/html_gitlab.rb
+++ b/lib/rouge/formatters/html_gitlab.rb
@@ -143,18 +143,14 @@ module Rouge
'</span>'
end
end
- lines.join("\n")
- else
- if @linenos == 'inline'
- lines = lines.each_with_index.map do |line, index|
- number = index + @linenostart
- "<span class=\"linenos\">#{number}</span>#{line}"
- end
- lines.join("\n")
- else
- lines.join("\n")
+ elsif @linenos == 'inline'
+ lines = lines.each_with_index.map do |line, index|
+ number = index + @linenostart
+ "<span class=\"linenos\">#{number}</span>#{line}"
end
end
+
+ lines.join("\n")
end
def span(tok, val)