Commit fcf6f623 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'id-redundant-return' into 'master'

Enable Style/RedundantReturn cop

See merge request gitlab-org/gitlab!36430
parents 4bb1828b e65b407a
...@@ -666,12 +666,6 @@ Style/RedundantFreeze: ...@@ -666,12 +666,6 @@ Style/RedundantFreeze:
Style/RedundantInterpolation: Style/RedundantInterpolation:
Enabled: false Enabled: false
# Offense count: 33
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
# Offense count: 801 # Offense count: 801
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/RedundantSelf: Style/RedundantSelf:
......
...@@ -306,7 +306,7 @@ class ApplicationController < ActionController::Base ...@@ -306,7 +306,7 @@ class ApplicationController < ActionController::Base
return if session[:impersonator_id] || !current_user&.allow_password_authentication? return if session[:impersonator_id] || !current_user&.allow_password_authentication?
if current_user&.password_expired? if current_user&.password_expired?
return redirect_to new_profile_password_path redirect_to new_profile_password_path
end end
end end
...@@ -364,7 +364,7 @@ class ApplicationController < ActionController::Base ...@@ -364,7 +364,7 @@ class ApplicationController < ActionController::Base
def require_email def require_email
if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil? if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil?
return redirect_to profile_path, notice: _('Please complete your profile with email address') redirect_to profile_path, notice: _('Please complete your profile with email address')
end end
end end
......
...@@ -45,7 +45,6 @@ class ChaosController < ActionController::Base ...@@ -45,7 +45,6 @@ class ChaosController < ActionController::Base
unless Devise.secure_compare(chaos_secret_configured, chaos_secret_request) unless Devise.secure_compare(chaos_secret_configured, chaos_secret_request)
render plain: "To experience chaos, please set a valid `X-Chaos-Secret` header or `token` param", render plain: "To experience chaos, please set a valid `X-Chaos-Secret` header or `token` param",
status: :unauthorized status: :unauthorized
return
end end
end end
......
...@@ -197,13 +197,13 @@ module IssuableActions ...@@ -197,13 +197,13 @@ module IssuableActions
def authorize_destroy_issuable! def authorize_destroy_issuable!
unless can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable) unless can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable)
return access_denied! access_denied!
end end
end end
def authorize_admin_issuable! def authorize_admin_issuable!
unless can?(current_user, :"admin_#{resource_name}", parent) unless can?(current_user, :"admin_#{resource_name}", parent)
return access_denied! access_denied!
end end
end end
......
...@@ -30,25 +30,25 @@ class Groups::ApplicationController < ApplicationController ...@@ -30,25 +30,25 @@ class Groups::ApplicationController < ApplicationController
def authorize_admin_group! def authorize_admin_group!
unless can?(current_user, :admin_group, group) unless can?(current_user, :admin_group, group)
return render_404 render_404
end end
end end
def authorize_create_deploy_token! def authorize_create_deploy_token!
unless can?(current_user, :create_deploy_token, group) unless can?(current_user, :create_deploy_token, group)
return render_404 render_404
end end
end end
def authorize_destroy_deploy_token! def authorize_destroy_deploy_token!
unless can?(current_user, :destroy_deploy_token, group) unless can?(current_user, :destroy_deploy_token, group)
return render_404 render_404
end end
end end
def authorize_admin_group_member! def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group) unless can?(current_user, :admin_group_member, group)
return render_403 render_403
end end
end end
......
...@@ -200,7 +200,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -200,7 +200,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def fail_login(user) def fail_login(user)
error_message = user.errors.full_messages.to_sentence error_message = user.errors.full_messages.to_sentence
return redirect_to omniauth_error_path(oauth['provider'], error: error_message) redirect_to omniauth_error_path(oauth['provider'], error: error_message)
end end
def fail_auth0_login def fail_auth0_login
......
...@@ -42,7 +42,7 @@ class Projects::ApplicationController < ApplicationController ...@@ -42,7 +42,7 @@ class Projects::ApplicationController < ApplicationController
def authorize_action!(action) def authorize_action!(action)
unless can?(current_user, action, project) unless can?(current_user, action, project)
return access_denied! access_denied!
end end
end end
......
...@@ -129,7 +129,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -129,7 +129,7 @@ class Projects::BlobController < Projects::ApplicationController
end end
end end
return redirect_to_tree_root_for_missing_path(@project, @ref, @path) redirect_to_tree_root_for_missing_path(@project, @ref, @path)
end end
end end
......
...@@ -30,7 +30,7 @@ class Projects::ReleasesController < Projects::ApplicationController ...@@ -30,7 +30,7 @@ class Projects::ReleasesController < Projects::ApplicationController
def new def new
unless Feature.enabled?(:new_release_page, project) unless Feature.enabled?(:new_release_page, project)
return redirect_to(new_project_tag_path(@project)) redirect_to(new_project_tag_path(@project))
end end
end end
......
...@@ -20,9 +20,9 @@ class Projects::TreeController < Projects::ApplicationController ...@@ -20,9 +20,9 @@ class Projects::TreeController < Projects::ApplicationController
if tree.entries.empty? if tree.entries.empty?
if @repository.blob_at(@commit.id, @path) if @repository.blob_at(@commit.id, @path)
return redirect_to project_blob_path(@project, File.join(@ref, @path)) redirect_to project_blob_path(@project, File.join(@ref, @path))
elsif @path.present? elsif @path.present?
return redirect_to_tree_root_for_missing_path(@project, @ref, @path) redirect_to_tree_root_for_missing_path(@project, @ref, @path)
end end
end end
end end
......
...@@ -37,7 +37,7 @@ module Resolvers ...@@ -37,7 +37,7 @@ module Resolvers
def jira_projects(name:) def jira_projects(name:)
args = { query: name }.compact args = { query: name }.compact
return Jira::Requests::Projects::ListService.new(project.jira_service, args).execute Jira::Requests::Projects::ListService.new(project.jira_service, args).execute
end end
end end
end end
......
...@@ -17,21 +17,21 @@ class AccessTokenValidationService ...@@ -17,21 +17,21 @@ class AccessTokenValidationService
def validate(scopes: []) def validate(scopes: [])
if token.expired? if token.expired?
return EXPIRED EXPIRED
elsif token.revoked? elsif token.revoked?
return REVOKED REVOKED
elsif !self.include_any_scope?(scopes) elsif !self.include_any_scope?(scopes)
return INSUFFICIENT_SCOPE INSUFFICIENT_SCOPE
elsif token.respond_to?(:impersonation) && elsif token.respond_to?(:impersonation) &&
token.impersonation && token.impersonation &&
!Gitlab.config.gitlab.impersonation_enabled !Gitlab.config.gitlab.impersonation_enabled
return IMPERSONATION_DISABLED IMPERSONATION_DISABLED
else else
return VALID VALID
end end
end end
......
...@@ -57,7 +57,7 @@ module Spam ...@@ -57,7 +57,7 @@ module Spam
rescue *Gitlab::HTTP::HTTP_ERRORS => e rescue *Gitlab::HTTP::HTTP_ERRORS => e
# @TODO: log error via try_post https://gitlab.com/gitlab-org/gitlab/-/issues/219223 # @TODO: log error via try_post https://gitlab.com/gitlab-org/gitlab/-/issues/219223
Gitlab::ErrorTracking.log_exception(e) Gitlab::ErrorTracking.log_exception(e)
return nil
rescue rescue
# @TODO log # @TODO log
ALLOW ALLOW
......
...@@ -17,7 +17,6 @@ class DeleteMergedBranchesWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -17,7 +17,6 @@ class DeleteMergedBranchesWorker # rubocop:disable Scalability/IdempotentWorker
begin begin
::Branches::DeleteMergedService.new(project, user).execute ::Branches::DeleteMergedService.new(project, user).execute
rescue Gitlab::Access::AccessDeniedError rescue Gitlab::Access::AccessDeniedError
return
end end
end end
end end
...@@ -33,7 +33,7 @@ module EE ...@@ -33,7 +33,7 @@ module EE
if unprocessed_too_old? if unprocessed_too_old?
minutes_behind = time_ago_in_words(next_unprocessed_event.created_at) minutes_behind = time_ago_in_words(next_unprocessed_event.created_at)
return (s_('Geo|The node is currently %{minutes_behind} behind the primary node.') % (s_('Geo|The node is currently %{minutes_behind} behind the primary node.') %
{ minutes_behind: minutes_behind }).html_safe { minutes_behind: minutes_behind }).html_safe
end end
end end
......
...@@ -74,7 +74,7 @@ module Epics ...@@ -74,7 +74,7 @@ module Epics
return 'Relative position is not valid.' unless valid_relative_position? return 'Relative position is not valid.' unless valid_relative_position?
if different_epic_parent? if different_epic_parent?
return "The sibling object's parent must match the #{new_parent ? "new" : "current"} parent epic." "The sibling object's parent must match the #{new_parent ? "new" : "current"} parent epic."
end end
end end
......
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
end end
def replication_verification_complete? def replication_verification_complete?
return replication_complete? && verification_complete? replication_complete? && verification_complete?
end end
private private
......
...@@ -84,7 +84,7 @@ module Gitlab ...@@ -84,7 +84,7 @@ module Gitlab
raise InvalidSignatureTimeError.new(message) raise InvalidSignatureTimeError.new(message)
rescue JWT::DecodeError => e rescue JWT::DecodeError => e
log_error("Error decoding Geo request: #{e}") log_error("Error decoding Geo request: #{e}")
return nil
end end
end end
......
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
end end
unless PERMITTED_FACETS.include?(aggregate_facet.to_sym) unless PERMITTED_FACETS.include?(aggregate_facet.to_sym)
return "Invalid aggregate facet #{aggregate_facet} provided." "Invalid aggregate facet #{aggregate_facet} provided."
end end
end end
......
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
end end
unless allowed_to_write_ref? unless allowed_to_write_ref?
return error("Insufficient permissions for protected ref '#{command.ref}'") error("Insufficient permissions for protected ref '#{command.ref}'")
end end
end end
......
...@@ -18,7 +18,7 @@ module Gitlab ...@@ -18,7 +18,7 @@ module Gitlab
end end
if @command.ambiguous_ref? if @command.ambiguous_ref?
return error('Ref is ambiguous') error('Ref is ambiguous')
end end
end end
......
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
begin begin
Rugged::Reference.valid_name?("refs/heads/#{ref_name}") Rugged::Reference.valid_name?("refs/heads/#{ref_name}")
rescue ArgumentError rescue ArgumentError
return false false
end end
end end
...@@ -35,7 +35,7 @@ module Gitlab ...@@ -35,7 +35,7 @@ module Gitlab
begin begin
Rugged::Reference.valid_name?(expanded_name) Rugged::Reference.valid_name?(expanded_name)
rescue ArgumentError rescue ArgumentError
return false false
end end
end end
end end
......
...@@ -201,9 +201,9 @@ module Gitlab ...@@ -201,9 +201,9 @@ module Gitlab
response = GitalyClient.call(@storage, :repository_service, :fsck, request, timeout: GitalyClient.long_timeout) response = GitalyClient.call(@storage, :repository_service, :fsck, request, timeout: GitalyClient.long_timeout)
if response.error.empty? if response.error.empty?
return "", 0 ["", 0]
else else
return response.error.b, 1 [response.error.b, 1]
end end
end end
......
...@@ -101,7 +101,7 @@ module Gitlab ...@@ -101,7 +101,7 @@ module Gitlab
if project if project
# If a project is found and the user has access, we return the full project path # If a project is found and the user has access, we return the full project path
return project.full_path, project.default_branch [project.full_path, project.default_branch]
else else
# If not, we return the first two components as if it were a simple `namespace/project` path, # If not, we return the first two components as if it were a simple `namespace/project` path,
# so that we don't reveal the existence of a nested project the user doesn't have access to. # so that we don't reveal the existence of a nested project the user doesn't have access to.
...@@ -112,7 +112,7 @@ module Gitlab ...@@ -112,7 +112,7 @@ module Gitlab
# `go get gitlab.com/group/subgroup/project/subpackage` will not work for private projects. # `go get gitlab.com/group/subgroup/project/subpackage` will not work for private projects.
# `go get gitlab.com/group/subgroup/project.git/subpackage` will work, since Go is smart enough # `go get gitlab.com/group/subgroup/project.git/subpackage` will work, since Go is smart enough
# to figure that out. `import 'gitlab.com/...'` behaves the same as `go get`. # to figure that out. `import 'gitlab.com/...'` behaves the same as `go get`.
return simple_project_path, 'master' [simple_project_path, 'master']
end end
end end
......
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
# * Maximum length is 63 bytes # * Maximum length is 63 bytes
# * First/Last Character is not a hyphen # * First/Last Character is not a hyphen
def slugify(str) def slugify(str)
return str.downcase str.downcase
.gsub(/[^a-z0-9]/, '-')[0..62] .gsub(/[^a-z0-9]/, '-')[0..62]
.gsub(/(\A-+|-+\z)/, '') .gsub(/(\A-+|-+\z)/, '')
end end
......
...@@ -22,7 +22,7 @@ module GoogleApi ...@@ -22,7 +22,7 @@ module GoogleApi
def get_token(code) def get_token(code)
ret = client.auth_code.get_token(code, redirect_uri: redirect_uri) ret = client.auth_code.get_token(code, redirect_uri: redirect_uri)
return ret.token, ret.expires_at [ret.token, ret.expires_at]
end end
protected protected
......
...@@ -121,15 +121,12 @@ module QA ...@@ -121,15 +121,12 @@ module QA
def set_file_template_if_not_already_set def set_file_template_if_not_already_set
response = get Runtime::API::Request.new(@api_client, "/groups/#{@group.id}").url response = get Runtime::API::Request.new(@api_client, "/groups/#{@group.id}").url
if parse_body(response)[:file_template_project_id] return if parse_body(response)[:file_template_project_id]
return
else
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform do |general| @group.visit!
general.choose_file_template_repository(@file_template_project.name) Page::Group::Menu.perform(&:click_group_general_settings_item)
end Page::Group::Settings::General.perform do |general|
general.choose_file_template_repository(@file_template_project.name)
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