Skip to content
Snippets Groups Projects
Commit 3288e1a8 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

Adds the Rubocop ReturnNil cop

This style change enforces `return if ...` instead of
`return nil if ...` to save maintainers a few minor review points
parent 7bbdb2a2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -15,7 +15,7 @@ module Gitlab
end
 
def expected_forms
return nil unless plural_information
return unless plural_information
 
plural_information['nplurals'].to_i
end
Loading
Loading
Loading
Loading
@@ -67,7 +67,7 @@ module Gitlab
# +value+ existing model to be included in the hash
# +parsed_hash+ the original hash
def parse_hash(value)
return nil if already_contains_methods?(value)
return if already_contains_methods?(value)
 
@attributes_finder.parse(value) do |hash|
{ include: hash_or_merge(value, hash) }
Loading
Loading
Loading
Loading
@@ -75,7 +75,7 @@ module Gitlab
# the relation_hash, updating references with new object IDs, mapping users using
# the "members_mapper" object, also updating notes if required.
def create
return nil if unknown_service?
return if unknown_service?
 
setup_models
 
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ module Gitlab
 
def address_regex
wildcard_address = config.address
return nil unless wildcard_address
return unless wildcard_address
 
regex = Regexp.escape(wildcard_address)
regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)')
Loading
Loading
Loading
Loading
@@ -68,7 +68,7 @@ module Gitlab
end
 
def user(login)
return nil unless login.present?
return unless login.present?
return @users[login] if @users.key?(login)
 
@users[login] = api.user(login)
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ module Gitlab
end
 
def find_by_email
return nil unless email
return unless email
 
User.find_by_any_email(email)
.try(:id)
Loading
Loading
@@ -33,7 +33,7 @@ module Gitlab
 
# rubocop: disable CodeReuse/ActiveRecord
def find_by_external_uid
return nil unless id
return unless id
 
identities = ::Identity.arel_table
 
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ module Gitlab
# `LOWER(column) = query` instead of using `ILIKE`.
def fuzzy_arel_match(column, query, lower_exact_match: false)
query = query.squish
return nil unless query.present?
return unless query.present?
 
words = select_fuzzy_words(query)
 
Loading
Loading
Loading
Loading
@@ -60,7 +60,7 @@ module Gitlab
elsif udp_endpoint.present?
sender = get_udp_sender(encoder, udp_endpoint)
else
return nil
return
end
 
Jaeger::Reporters::RemoteReporter.new(
Loading
Loading
Loading
Loading
@@ -95,7 +95,7 @@ module Gitlab
end
 
def cache_commit(commit)
return nil unless commit.present?
return unless commit.present?
 
resolved_commits[commit.id] ||= commit
end
Loading
Loading
Loading
Loading
@@ -53,7 +53,7 @@ module SystemCheck
end
 
def ssh_dir
return nil unless home_dir
return unless home_dir
 
File.join(home_dir, '.ssh')
end
Loading
Loading
Loading
Loading
@@ -91,7 +91,7 @@ module ExportFileHelper
loop do
object_with_parent = deep_find_with_parent(sensitive_word, project_hash)
 
return nil unless object_with_parent && object_with_parent.object
return unless object_with_parent && object_with_parent.object
 
if is_safe_hash?(object_with_parent.parent, sensitive_word)
# It's in the safe list, remove hash and keep looking
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