Commit 0151f26f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'rubocop-rails-presence' into 'master'

Fix Rubocop offense Rails/Presence

See merge request gitlab-org/gitlab!17631
parents 47b719c2 f82c2bbf
......@@ -442,19 +442,6 @@ Rails/LinkToBlank:
- 'ee/app/helpers/ee/user_callouts_helper.rb'
- 'ee/app/helpers/license_helper.rb'
# Offense count: 11
# Cop supports --auto-correct.
Rails/Presence:
Exclude:
- 'app/models/ci/pipeline.rb'
- 'app/models/concerns/mentionable.rb'
- 'app/models/project_services/hipchat_service.rb'
- 'app/models/project_services/irker_service.rb'
- 'app/models/project_services/jira_service.rb'
- 'app/models/project_services/packagist_service.rb'
- 'app/models/wiki_page.rb'
- 'lib/gitlab/github_import/importer/releases_importer.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
......
......@@ -584,11 +584,7 @@ module Ci
def ci_yaml_file_path
return unless repository_source? || unknown_source?
if project.ci_config_path.blank?
'.gitlab-ci.yml'
else
project.ci_config_path
end
project.ci_config_path.presence || '.gitlab-ci.yml'
end
def ci_yaml_file
......
......@@ -150,7 +150,7 @@ module Mentionable
#
# Returns a Hash.
def detect_mentionable_changes
source = (changes.present? ? changes : previous_changes).dup
source = (changes.presence || previous_changes).dup
mentionable = self.class.mentionable_attrs.map { |attr, options| attr }
......
......@@ -73,7 +73,7 @@ class HipchatService < Service
private
def gate
options = { api_version: api_version.present? ? api_version : 'v2' }
options = { api_version: api_version.presence || 'v2' }
options[:server_url] = server unless server.blank?
@gate ||= HipChat::Client.new(token, options)
end
......
......@@ -36,8 +36,8 @@ class IrkerService < Service
def settings
{
server_host: server_host.present? ? server_host : 'localhost',
server_port: server_port.present? ? server_port : 6659
server_host: server_host.presence || 'localhost',
server_port: server_port.presence || 6659
}
end
......
......@@ -337,7 +337,7 @@ class JiraService < IssueTrackerService
end
def client_url
api_url.present? ? api_url : url
api_url.presence || url
end
def reset_password?
......
......@@ -59,7 +59,7 @@ class PackagistService < Service
end
def hook_url
base_url = server.present? ? server : 'https://packagist.org'
base_url = server.presence || 'https://packagist.org'
"#{base_url}/api/update-package?username=#{username}&apiToken=#{token}"
end
end
......@@ -77,11 +77,7 @@ class WikiPage
# The escaped URL path of this page.
def slug
if @attributes[:slug].present?
@attributes[:slug]
else
wiki.wiki.preview_slug(title, format)
end
@attributes[:slug].presence || wiki.wiki.preview_slug(title, format)
end
alias_method :to_param, :slug
......
......@@ -47,11 +47,7 @@ module Gitlab
end
def description_for(release)
if release.body.present?
release.body
else
"Release for tag #{release.tag_name}"
end
release.body.presence || "Release for tag #{release.tag_name}"
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