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