Skip to content
Snippets Groups Projects
Commit 0d1a671b authored by Igor Drozdov's avatar Igor Drozdov
Browse files

Enable Style/RedundantReturn cop

This commit also fixes the existing offenses
parent 2f7d087b
No related branches found
No related tags found
No related merge requests found
Showing
with 27 additions and 35 deletions
Loading
Loading
@@ -666,12 +666,6 @@ Style/RedundantFreeze:
Style/RedundantInterpolation:
Enabled: false
 
# Offense count: 33
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
# Offense count: 801
# Cop supports --auto-correct.
Style/RedundantSelf:
Loading
Loading
Loading
Loading
@@ -306,7 +306,7 @@ class ApplicationController < ActionController::Base
return if session[:impersonator_id] || !current_user&.allow_password_authentication?
 
if current_user&.password_expired?
return redirect_to new_profile_password_path
redirect_to new_profile_password_path
end
end
 
Loading
Loading
@@ -364,7 +364,7 @@ class ApplicationController < ActionController::Base
 
def require_email
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
 
Loading
Loading
Loading
Loading
@@ -45,7 +45,6 @@ class ChaosController < ActionController::Base
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",
status: :unauthorized
return
end
end
 
Loading
Loading
Loading
Loading
@@ -197,13 +197,13 @@ module IssuableActions
 
def authorize_destroy_issuable!
unless can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable)
return access_denied!
access_denied!
end
end
 
def authorize_admin_issuable!
unless can?(current_user, :"admin_#{resource_name}", parent)
return access_denied!
access_denied!
end
end
 
Loading
Loading
Loading
Loading
@@ -30,25 +30,25 @@ class Groups::ApplicationController < ApplicationController
 
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
return render_404
render_404
end
end
 
def authorize_create_deploy_token!
unless can?(current_user, :create_deploy_token, group)
return render_404
render_404
end
end
 
def authorize_destroy_deploy_token!
unless can?(current_user, :destroy_deploy_token, group)
return render_404
render_404
end
end
 
def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group)
return render_403
render_403
end
end
 
Loading
Loading
Loading
Loading
@@ -200,7 +200,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def fail_login(user)
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
 
def fail_auth0_login
Loading
Loading
Loading
Loading
@@ -42,7 +42,7 @@ class Projects::ApplicationController < ApplicationController
 
def authorize_action!(action)
unless can?(current_user, action, project)
return access_denied!
access_denied!
end
end
 
Loading
Loading
Loading
Loading
@@ -129,7 +129,7 @@ class Projects::BlobController < Projects::ApplicationController
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
 
Loading
Loading
Loading
Loading
@@ -20,9 +20,9 @@ class Projects::TreeController < Projects::ApplicationController
 
if tree.entries.empty?
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?
return redirect_to_tree_root_for_missing_path(@project, @ref, @path)
redirect_to_tree_root_for_missing_path(@project, @ref, @path)
end
end
end
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ module Resolvers
def jira_projects(name:)
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
Loading
Loading
Loading
Loading
@@ -17,21 +17,21 @@ class AccessTokenValidationService
 
def validate(scopes: [])
if token.expired?
return EXPIRED
EXPIRED
 
elsif token.revoked?
return REVOKED
REVOKED
 
elsif !self.include_any_scope?(scopes)
return INSUFFICIENT_SCOPE
INSUFFICIENT_SCOPE
 
elsif token.respond_to?(:impersonation) &&
token.impersonation &&
!Gitlab.config.gitlab.impersonation_enabled
return IMPERSONATION_DISABLED
IMPERSONATION_DISABLED
 
else
return VALID
VALID
end
end
 
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ module Spam
rescue *Gitlab::HTTP::HTTP_ERRORS => e
# @TODO: log error via try_post https://gitlab.com/gitlab-org/gitlab/-/issues/219223
Gitlab::ErrorTracking.log_exception(e)
return
nil
rescue
# @TODO log
ALLOW
Loading
Loading
Loading
Loading
@@ -17,7 +17,6 @@ class DeleteMergedBranchesWorker # rubocop:disable Scalability/IdempotentWorker
begin
::Branches::DeleteMergedService.new(project, user).execute
rescue Gitlab::Access::AccessDeniedError
return
end
end
end
Loading
Loading
@@ -33,7 +33,7 @@ module EE
 
if unprocessed_too_old?
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
end
end
Loading
Loading
Loading
Loading
@@ -74,7 +74,7 @@ module Epics
return 'Relative position is not valid.' unless valid_relative_position?
 
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
 
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ module Gitlab
end
 
def replication_verification_complete?
return replication_complete? && verification_complete?
replication_complete? && verification_complete?
end
 
private
Loading
Loading
Loading
Loading
@@ -84,7 +84,7 @@ module Gitlab
raise InvalidSignatureTimeError.new(message)
rescue JWT::DecodeError => e
log_error("Error decoding Geo request: #{e}")
return
nil
end
end
 
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ module Gitlab
end
 
unless PERMITTED_FACETS.include?(aggregate_facet.to_sym)
return "Invalid aggregate facet #{aggregate_facet} provided."
"Invalid aggregate facet #{aggregate_facet} provided."
end
end
 
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module Gitlab
end
 
unless allowed_to_write_ref?
return error("Insufficient permissions for protected ref '#{command.ref}'")
error("Insufficient permissions for protected ref '#{command.ref}'")
end
end
 
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ module Gitlab
end
 
if @command.ambiguous_ref?
return error('Ref is ambiguous')
error('Ref is ambiguous')
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment