Commit 170efaab authored by Rydkin Maxim's avatar Rydkin Maxim

Enable Style/MultilineOperationIndentation in Rubocop, fixes #25741

parent b1120fc3
...@@ -292,7 +292,8 @@ Style/MultilineMethodDefinitionBraceLayout: ...@@ -292,7 +292,8 @@ Style/MultilineMethodDefinitionBraceLayout:
# Checks indentation of binary operations that span more than one line. # Checks indentation of binary operations that span more than one line.
Style/MultilineOperationIndentation: Style/MultilineOperationIndentation:
Enabled: false Enabled: true
EnforcedStyle: indented
# Avoid multi-line `? :` (the ternary operator), use if/unless instead. # Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator: Style/MultilineTernaryOperator:
......
...@@ -26,7 +26,7 @@ class JwtController < ApplicationController ...@@ -26,7 +26,7 @@ class JwtController < ApplicationController
@authentication_result = Gitlab::Auth.find_for_git_client(login, password, project: nil, ip: request.ip) @authentication_result = Gitlab::Auth.find_for_git_client(login, password, project: nil, ip: request.ip)
render_unauthorized unless @authentication_result.success? && render_unauthorized unless @authentication_result.success? &&
(@authentication_result.actor.nil? || @authentication_result.actor.is_a?(User)) (@authentication_result.actor.nil? || @authentication_result.actor.is_a?(User))
end end
rescue Gitlab::Auth::MissingPersonalTokenError rescue Gitlab::Auth::MissingPersonalTokenError
render_missing_personal_token render_missing_personal_token
......
...@@ -114,7 +114,7 @@ class SessionsController < Devise::SessionsController ...@@ -114,7 +114,7 @@ class SessionsController < Devise::SessionsController
def valid_otp_attempt?(user) def valid_otp_attempt?(user)
user.validate_and_consume_otp!(user_params[:otp_attempt]) || user.validate_and_consume_otp!(user_params[:otp_attempt]) ||
user.invalidate_otp_backup_code!(user_params[:otp_attempt]) user.invalidate_otp_backup_code!(user_params[:otp_attempt])
end end
def log_audit_event(user, options = {}) def log_audit_event(user, options = {})
......
...@@ -7,12 +7,12 @@ module FormHelper ...@@ -7,12 +7,12 @@ module FormHelper
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
content_tag(:h4, headline) << content_tag(:h4, headline) <<
content_tag(:ul) do content_tag(:ul) do
model.errors.full_messages. model.errors.full_messages.
map { |msg| content_tag(:li, msg) }. map { |msg| content_tag(:li, msg) }.
join. join.
html_safe html_safe
end end
end end
end end
end end
...@@ -7,12 +7,12 @@ module NavHelper ...@@ -7,12 +7,12 @@ module NavHelper
def page_gutter_class def page_gutter_class
if current_path?('merge_requests#show') || if current_path?('merge_requests#show') ||
current_path?('merge_requests#diffs') || current_path?('merge_requests#diffs') ||
current_path?('merge_requests#commits') || current_path?('merge_requests#commits') ||
current_path?('merge_requests#builds') || current_path?('merge_requests#builds') ||
current_path?('merge_requests#conflicts') || current_path?('merge_requests#conflicts') ||
current_path?('merge_requests#pipelines') || current_path?('merge_requests#pipelines') ||
current_path?('issues#show') current_path?('issues#show')
if cookies[:collapsed_gutter] == 'true' if cookies[:collapsed_gutter] == 'true'
"page-gutter right-sidebar-collapsed" "page-gutter right-sidebar-collapsed"
else else
...@@ -21,9 +21,9 @@ module NavHelper ...@@ -21,9 +21,9 @@ module NavHelper
elsif current_path?('builds#show') elsif current_path?('builds#show')
"page-gutter build-sidebar right-sidebar-expanded" "page-gutter build-sidebar right-sidebar-expanded"
elsif current_path?('wikis#show') || elsif current_path?('wikis#show') ||
current_path?('wikis#edit') || current_path?('wikis#edit') ||
current_path?('wikis#history') || current_path?('wikis#history') ||
current_path?('wikis#git_access') current_path?('wikis#git_access')
"page-gutter wiki-sidebar right-sidebar-expanded" "page-gutter wiki-sidebar right-sidebar-expanded"
end end
end end
......
...@@ -106,9 +106,9 @@ module TabHelper ...@@ -106,9 +106,9 @@ module TabHelper
def branches_tab_class def branches_tab_class
if current_controller?(:protected_branches) || if current_controller?(:protected_branches) ||
current_controller?(:branches) || current_controller?(:branches) ||
current_page?(namespace_project_repository_path(@project.namespace, current_page?(namespace_project_repository_path(@project.namespace,
@project)) @project))
'active' 'active'
end end
end end
......
...@@ -89,8 +89,8 @@ class Member < ActiveRecord::Base ...@@ -89,8 +89,8 @@ class Member < ActiveRecord::Base
member = member =
if user.is_a?(User) if user.is_a?(User)
source.members.find_by(user_id: user.id) || source.members.find_by(user_id: user.id) ||
source.requesters.find_by(user_id: user.id) || source.requesters.find_by(user_id: user.id) ||
source.members.build(user_id: user.id) source.members.build(user_id: user.id)
else else
source.members.build(invite_email: user) source.members.build(invite_email: user)
end end
......
...@@ -161,8 +161,8 @@ module Network ...@@ -161,8 +161,8 @@ module Network
def is_overlap?(range, overlap_space) def is_overlap?(range, overlap_space)
range.each do |i| range.each do |i|
if i != range.first && if i != range.first &&
i != range.last && i != range.last &&
@commits[i].spaces.include?(overlap_space) @commits[i].spaces.include?(overlap_space)
return true return true
end end
......
...@@ -85,8 +85,8 @@ class IssueTrackerService < Service ...@@ -85,8 +85,8 @@ class IssueTrackerService < Service
def enabled_in_gitlab_config def enabled_in_gitlab_config
Gitlab.config.issues_tracker && Gitlab.config.issues_tracker &&
Gitlab.config.issues_tracker.values.any? && Gitlab.config.issues_tracker.values.any? &&
issues_tracker issues_tracker
end end
def issues_tracker def issues_tracker
......
...@@ -390,7 +390,7 @@ class User < ActiveRecord::Base ...@@ -390,7 +390,7 @@ class User < ActiveRecord::Base
def namespace_uniq def namespace_uniq
# Return early if username already failed the first uniqueness validation # Return early if username already failed the first uniqueness validation
return if errors.key?(:username) && return if errors.key?(:username) &&
errors[:username].include?('has already been taken') errors[:username].include?('has already been taken')
existing_namespace = Namespace.by_path(username) existing_namespace = Namespace.by_path(username)
if existing_namespace && existing_namespace != namespace if existing_namespace && existing_namespace != namespace
......
...@@ -12,7 +12,7 @@ class NotePolicy < BasePolicy ...@@ -12,7 +12,7 @@ class NotePolicy < BasePolicy
end end
if @subject.for_merge_request? && if @subject.for_merge_request? &&
@subject.noteable.author == @user @subject.noteable.author == @user
can! :resolve_note can! :resolve_note
end end
end end
......
...@@ -3,7 +3,7 @@ class ProjectPolicy < BasePolicy ...@@ -3,7 +3,7 @@ class ProjectPolicy < BasePolicy
team_access!(user) team_access!(user)
owner = project.owner == user || owner = project.owner == user ||
(project.group && project.group.has_owner?(user)) (project.group && project.group.has_owner?(user))
owner_access! if user.admin? || owner owner_access! if user.admin? || owner
team_member_owner_access! if owner team_member_owner_access! if owner
...@@ -13,7 +13,7 @@ class ProjectPolicy < BasePolicy ...@@ -13,7 +13,7 @@ class ProjectPolicy < BasePolicy
public_access! public_access!
if project.request_access_enabled && if project.request_access_enabled &&
!(owner || user.admin? || project.team.member?(user) || project_group_member?(user)) !(owner || user.admin? || project.team.member?(user) || project_group_member?(user))
can! :request_access can! :request_access
end end
end end
...@@ -244,10 +244,10 @@ class ProjectPolicy < BasePolicy ...@@ -244,10 +244,10 @@ class ProjectPolicy < BasePolicy
def project_group_member?(user) def project_group_member?(user)
project.group && project.group &&
( (
project.group.members.exists?(user_id: user.id) || project.group.members.exists?(user_id: user.id) ||
project.group.requesters.exists?(user_id: user.id) project.group.requesters.exists?(user_id: user.id)
) )
end end
def named_abilities(name) def named_abilities(name)
......
...@@ -5,7 +5,7 @@ module Groups ...@@ -5,7 +5,7 @@ module Groups
new_visibility = params[:visibility_level] new_visibility = params[:visibility_level]
if new_visibility && new_visibility.to_i != group.visibility_level if new_visibility && new_visibility.to_i != group.visibility_level
unless can?(current_user, :change_visibility_level, group) && unless can?(current_user, :change_visibility_level, group) &&
Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
deny_visibility_level(group, new_visibility) deny_visibility_level(group, new_visibility)
return group return group
......
...@@ -10,7 +10,7 @@ module Issues ...@@ -10,7 +10,7 @@ module Issues
end end
if issue.previous_changes.include?('title') || if issue.previous_changes.include?('title') ||
issue.previous_changes.include?('description') issue.previous_changes.include?('description')
todo_service.update_issue(issue, current_user) todo_service.update_issue(issue, current_user)
end end
......
...@@ -42,7 +42,7 @@ module MergeRequests ...@@ -42,7 +42,7 @@ module MergeRequests
end end
if merge_request.source_project == merge_request.target_project && if merge_request.source_project == merge_request.target_project &&
merge_request.target_branch == merge_request.source_branch merge_request.target_branch == merge_request.source_branch
messages << 'You must select different branches' messages << 'You must select different branches'
end end
......
...@@ -25,7 +25,7 @@ module MergeRequests ...@@ -25,7 +25,7 @@ module MergeRequests
end end
if merge_request.previous_changes.include?('title') || if merge_request.previous_changes.include?('title') ||
merge_request.previous_changes.include?('description') merge_request.previous_changes.include?('description')
todo_service.update_merge_request(merge_request, current_user) todo_service.update_merge_request(merge_request, current_user)
end end
......
...@@ -6,7 +6,7 @@ module Projects ...@@ -6,7 +6,7 @@ module Projects
if new_visibility && new_visibility.to_i != project.visibility_level if new_visibility && new_visibility.to_i != project.visibility_level
unless can?(current_user, :change_visibility_level, project) && unless can?(current_user, :change_visibility_level, project) &&
Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
deny_visibility_level(project, new_visibility) deny_visibility_level(project, new_visibility)
return project return project
......
...@@ -34,7 +34,7 @@ Sidekiq.configure_server do |config| ...@@ -34,7 +34,7 @@ Sidekiq.configure_server do |config|
# Database pool should be at least `sidekiq_concurrency` + 2 # Database pool should be at least `sidekiq_concurrency` + 2
# For more info, see: https://github.com/mperham/sidekiq/blob/master/4.0-Upgrade.md # For more info, see: https://github.com/mperham/sidekiq/blob/master/4.0-Upgrade.md
config = ActiveRecord::Base.configurations[Rails.env] || config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env] Rails.application.config.database_configuration[Rails.env]
config['pool'] = Sidekiq.options[:concurrency] + 2 config['pool'] = Sidekiq.options[:concurrency] + 2
ActiveRecord::Base.establish_connection(config) ActiveRecord::Base.establish_connection(config)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
......
...@@ -69,7 +69,7 @@ module Gitlab ...@@ -69,7 +69,7 @@ module Gitlab
# This one might be controversial but so many reply lines have years, times and end with a colon. # This one might be controversial but so many reply lines have years, times and end with a colon.
# Let's try it and see how well it works. # Let's try it and see how well it works.
break if (l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) || break if (l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) ||
(l =~ /On \w+ \d+,? \d+,?.*wrote:/) (l =~ /On \w+ \d+,? \d+,?.*wrote:/)
# Headers on subsequent lines # Headers on subsequent lines
break if (0..2).all? { |off| lines[idx + off] =~ REPLYING_HEADER_REGEX } break if (0..2).all? { |off| lines[idx + off] =~ REPLYING_HEADER_REGEX }
......
...@@ -29,7 +29,7 @@ describe Gitlab::Gfm::ReferenceRewriter do ...@@ -29,7 +29,7 @@ describe Gitlab::Gfm::ReferenceRewriter do
context 'description with ignored elements' do context 'description with ignored elements' do
let(:text) do let(:text) do
"Hi. This references #1, but not `#2`\n" + "Hi. This references #1, but not `#2`\n" +
'<pre>and not !1</pre>' '<pre>and not !1</pre>'
end end
it { is_expected.to include issue_first.to_reference(new_project) } it { is_expected.to include issue_first.to_reference(new_project) }
......
...@@ -167,7 +167,7 @@ describe API::Projects, api: true do ...@@ -167,7 +167,7 @@ describe API::Projects, api: true do
expect(json_response).to satisfy do |response| expect(json_response).to satisfy do |response|
response.one? do |entry| response.one? do |entry|
entry.has_key?('permissions') && entry.has_key?('permissions') &&
entry['name'] == project.name && entry['name'] == project.name &&
entry['owner']['username'] == user.username entry['owner']['username'] == user.username
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment