summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/impersonations_controller.rb2
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb2
-rw-r--r--app/controllers/concerns/lfs_request.rb2
-rw-r--r--app/controllers/concerns/sends_blob.rb4
-rw-r--r--app/controllers/concerns/uploads_actions.rb2
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb2
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb2
-rw-r--r--app/controllers/passwords_controller.rb2
-rw-r--r--app/controllers/projects/build_artifacts_controller.rb2
-rw-r--r--app/controllers/projects/lfs_storage_controller.rb2
-rw-r--r--app/controllers/sent_notifications_controller.rb2
-rw-r--r--app/controllers/sessions_controller.rb2
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/blob_helper.rb4
-rw-r--r--app/helpers/diff_helper.rb4
-rw-r--r--app/helpers/issuables_helper.rb2
-rw-r--r--app/helpers/namespaces_helper.rb2
-rw-r--r--app/helpers/runners_helper.rb2
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--app/helpers/tree_helper.rb2
-rw-r--r--app/models/application_setting_implementation.rb2
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/concerns/discussion_on_diff.rb3
-rw-r--r--app/models/concerns/ghost_user.rb2
-rw-r--r--app/models/concerns/milestoneish.rb4
-rw-r--r--app/models/concerns/spammable.rb2
-rw-r--r--app/models/concerns/strip_attribute.rb2
-rw-r--r--app/models/group.rb2
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/merge_request.rb6
-rw-r--r--app/models/project_services/issue_tracker_service.rb3
-rw-r--r--app/models/ref_matcher.rb2
-rw-r--r--app/policies/global_policy.rb2
-rw-r--r--app/serializers/environment_entity.rb2
-rw-r--r--app/services/compare_service.rb2
-rw-r--r--app/services/merge_requests/update_service.rb2
-rw-r--r--app/services/projects/create_service.rb4
-rw-r--r--app/uploaders/avatar_uploader.rb2
-rw-r--r--app/uploaders/object_storage.rb2
-rw-r--r--app/uploaders/records_uploads.rb6
-rw-r--r--app/validators/branch_filter_validator.rb2
-rw-r--r--app/workers/post_receive.rb6
43 files changed, 54 insertions, 58 deletions
diff --git a/app/controllers/admin/impersonations_controller.rb b/app/controllers/admin/impersonations_controller.rb
index 65fe22bd8f4..f0e160258f8 100644
--- a/app/controllers/admin/impersonations_controller.rb
+++ b/app/controllers/admin/impersonations_controller.rb
@@ -12,6 +12,6 @@ class Admin::ImpersonationsController < Admin::ApplicationController
private
def authenticate_impersonator!
- render_404 unless impersonator && impersonator.admin? && !impersonator.blocked?
+ render_404 unless impersonator&.admin? && !impersonator.blocked?
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 75108bf2646..ed7e5318c95 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -289,7 +289,7 @@ class ApplicationController < ActionController::Base
end
def ldap_security_check
- if current_user && current_user.requires_ldap_check?
+ if current_user&.requires_ldap_check?
return unless current_user.try_obtain_ldap_lease
unless Gitlab::Auth::LDAP::Access.allowed?(current_user)
@@ -340,7 +340,7 @@ class ApplicationController < ActionController::Base
end
def require_email
- if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil?
+ if current_user&.temp_oauth_email? && session[:impersonator_id].nil?
return redirect_to profile_path, notice: _('Please complete your profile with email address')
end
end
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 4926062f9ca..471493df3e0 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -41,7 +41,7 @@ module AuthenticatesWithTwoFactor
authenticate_with_two_factor_via_otp(user)
elsif user_params[:device_response].present? && session[:otp_user_id]
authenticate_with_two_factor_via_u2f(user)
- elsif user && user.valid_password?(user_params[:password])
+ elsif user&.valid_password?(user_params[:password])
prompt_for_two_factor(user)
end
end
diff --git a/app/controllers/concerns/lfs_request.rb b/app/controllers/concerns/lfs_request.rb
index f7137a04437..290cb5b4c95 100644
--- a/app/controllers/concerns/lfs_request.rb
+++ b/app/controllers/concerns/lfs_request.rb
@@ -84,7 +84,7 @@ module LfsRequest
end
def deploy_token_present?
- user && user.is_a?(DeployToken)
+ user&.is_a?(DeployToken)
end
def deploy_token
diff --git a/app/controllers/concerns/sends_blob.rb b/app/controllers/concerns/sends_blob.rb
index 8ecdaced9f5..7f715d0d4ec 100644
--- a/app/controllers/concerns/sends_blob.rb
+++ b/app/controllers/concerns/sends_blob.rb
@@ -51,7 +51,7 @@ module SendsBlob
def send_lfs_object(blob)
lfs_object = find_lfs_object(blob)
- if lfs_object && lfs_object.project_allowed_access?(project)
+ if lfs_object&.project_allowed_access?(project)
send_upload(lfs_object.file, attachment: blob.name)
else
render_404
@@ -60,7 +60,7 @@ module SendsBlob
def find_lfs_object(blob)
lfs_object = LfsObject.find_by_oid(blob.lfs_oid)
- if lfs_object && lfs_object.file.exists?
+ if lfs_object&.file&.exists?
lfs_object
else
nil
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index 59f6d3452a3..78767c1d169 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -113,7 +113,7 @@ module UploadsActions
end
def image_or_video?
- uploader && uploader.exists? && uploader.image_or_video?
+ uploader&.exists? && uploader.image_or_video?
end
def find_model
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index 89889141be6..24441e31b22 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -31,7 +31,7 @@ class Import::GitlabProjectsController < Import::BaseController
private
def file_is_valid?
- return false unless project_params[:file] && project_params[:file].respond_to?(:read)
+ return false unless project_params[:file]&.respond_to?(:read)
filename = project_params[:file].original_filename
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 2a8dd997d04..4962a187824 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -35,7 +35,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
error ||= exception.message if exception.respond_to?(:message)
error ||= request.env["omniauth.error.type"].to_s
- error.to_s.humanize if error
+ error&.to_s&.humanize
end
def saml
diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb
index 77de5cb45c9..cd48584e987 100644
--- a/app/controllers/passwords_controller.rb
+++ b/app/controllers/passwords_controller.rb
@@ -56,7 +56,7 @@ class PasswordsController < Devise::PasswordsController
end
def throttle_reset
- return unless resource && resource.recently_sent_password_reset?
+ return unless resource&.recently_sent_password_reset?
# Throttle reset attempts, but return a normal message to
# avoid user enumeration attack.
diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb
index 4274c356227..7c1b98930f8 100644
--- a/app/controllers/projects/build_artifacts_controller.rb
+++ b/app/controllers/projects/build_artifacts_controller.rb
@@ -31,7 +31,7 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
private
def validate_artifacts!
- render_404 unless job && job.artifacts?
+ render_404 unless job&.artifacts?
end
def extract_ref_name_and_path
diff --git a/app/controllers/projects/lfs_storage_controller.rb b/app/controllers/projects/lfs_storage_controller.rb
index 013e01b82aa..12abe7f5093 100644
--- a/app/controllers/projects/lfs_storage_controller.rb
+++ b/app/controllers/projects/lfs_storage_controller.rb
@@ -9,7 +9,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
def download
lfs_object = LfsObject.find_by_oid(oid)
- unless lfs_object && lfs_object.file.exists?
+ unless lfs_object&.file&.exists?
render_lfs_not_found
return
end
diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb
index 77757c4a3ef..7b7055c1fb1 100644
--- a/app/controllers/sent_notifications_controller.rb
+++ b/app/controllers/sent_notifications_controller.rb
@@ -6,7 +6,7 @@ class SentNotificationsController < ApplicationController
def unsubscribe
@sent_notification = SentNotification.for(params[:id])
- return render_404 unless @sent_notification && @sent_notification.unsubscribable?
+ return render_404 unless @sent_notification&.unsubscribable?
return unsubscribe_and_redirect if current_user || params[:force]
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index a841859621e..fe5de61fa6b 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -128,7 +128,7 @@ class SessionsController < Devise::SessionsController
user = User.admins.last
- return unless user && user.require_password_creation_for_web?
+ return unless user&.require_password_creation_for_web?
Users::UpdateService.new(current_user, user: user).execute do |user|
@token = user.generate_reset_token
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ffa5719fefb..1cfc4cf6cdc 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -69,7 +69,7 @@ module ApplicationHelper
# rubocop: disable CodeReuse/ActiveRecord
def show_last_push_widget?(event)
# Skip if event is not about added or modified non-master branch
- return false unless event && event.last_push_to_non_root? && !event.rm_ref?
+ return false unless event&.last_push_to_non_root? && !event.rm_ref?
project = event.project
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 0d6a6496993..1a2abc19dcc 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -181,9 +181,9 @@ module BlobHelper
{
'relative-url-root' => Rails.application.config.relative_url_root,
'assets-prefix' => Gitlab::Application.config.assets.prefix,
- 'blob-filename' => @blob && @blob.path,
+ 'blob-filename' => @blob&.path,
'project-id' => project.id,
- 'is-markdown' => @blob && @blob.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path)
+ 'is-markdown' => @blob&.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path)
}
end
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 32431959851..77c2622304c 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -71,12 +71,12 @@ module DiffHelper
discussions_left = discussions_right = nil
- if left && left.discussable? && (left.unchanged? || left.removed?)
+ if left&.discussable? && (left.unchanged? || left.removed?)
line_code = diff_file.line_code(left)
discussions_left = @grouped_diff_discussions[line_code]
end
- if right && right.discussable? && right.added?
+ if right&.discussable? && right.added?
line_code = diff_file.line_code(right)
discussions_right = @grouped_diff_discussions[line_code]
end
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 045de105b77..4036753fecf 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -214,7 +214,7 @@ module IssuablesHelper
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
- if labels && labels.any?
+ if labels&.any?
label_names = first.collect { |label| label.fetch(:title) }
label_names << "and #{last.size} more" unless last.empty?
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index 572d68cb4a3..5e271f18693 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -14,7 +14,7 @@ module NamespacesHelper
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
end
- if extra_group && extra_group.is_a?(Group)
+ if extra_group&.is_a?(Group)
extra_group = dedup_extra_group(extra_group)
if Ability.allowed?(current_user, :read_group, extra_group)
diff --git a/app/helpers/runners_helper.rb b/app/helpers/runners_helper.rb
index 0d880c38a7b..d6dd4c3fe6d 100644
--- a/app/helpers/runners_helper.rb
+++ b/app/helpers/runners_helper.rb
@@ -20,7 +20,7 @@ module RunnersHelper
display_name = truncate(runner.display_name, length: 15)
id = "\##{runner.id}"
- if current_user && current_user.admin
+ if current_user&.admin
link_to admin_runner_path(runner) do
display_name + id
end
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index f5c4686a3bf..2544dfc7130 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -89,7 +89,7 @@ module SearchHelper
# Autocomplete results for the current project, if it's defined
def project_autocomplete
- if @project && @project.repository.exists? && @project.repository.root_ref
+ if @project&.repository&.exists? && @project.repository.root_ref
ref = @ref || @project.repository.root_ref
[
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 4690b6ffbe1..3f4e3e24429 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -80,7 +80,7 @@ module TreeHelper
def tree_edit_project(project = @project)
if can?(current_user, :push_code, project)
project
- elsif current_user && current_user.already_forked?(project)
+ elsif current_user&.already_forked?(project)
current_user.fork_of(project)
end
end
diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb
index df4caed175d..30fbd6c4b37 100644
--- a/app/models/application_setting_implementation.rb
+++ b/app/models/application_setting_implementation.rb
@@ -250,7 +250,7 @@ module ApplicationSettingImplementation
end
def archive_builds_older_than
- archive_builds_in_seconds.seconds.ago if archive_builds_in_seconds
+ archive_builds_in_seconds&.seconds&.ago
end
private
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 89cc082d0bc..a53471ef936 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -397,7 +397,7 @@ module Ci
end
def environment_action
- self.options.fetch(:environment, {}).fetch(:action, 'start') if self.options
+ self.options&.fetch(:environment, {})&.fetch(:action, 'start')
end
def has_deployment?
diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb
index e4e5928f5cf..1a1631c357a 100644
--- a/app/models/concerns/discussion_on_diff.rb
+++ b/app/models/concerns/discussion_on_diff.rb
@@ -79,8 +79,7 @@ module DiscussionOnDiff
def fetch_preloaded_diff_file
fetch_preloaded_diff =
- context_noteable &&
- context_noteable.preloads_discussion_diff_highlighting? &&
+ context_noteable&.preloads_discussion_diff_highlighting? &&
note_diff_file
context_noteable.discussions_diffs.find_by_id(note_diff_file.id) if fetch_preloaded_diff
diff --git a/app/models/concerns/ghost_user.rb b/app/models/concerns/ghost_user.rb
index 15278c431fb..e7255ae710a 100644
--- a/app/models/concerns/ghost_user.rb
+++ b/app/models/concerns/ghost_user.rb
@@ -4,6 +4,6 @@ module GhostUser
extend ActiveSupport::Concern
def ghost_user?
- user && user.ghost?
+ user&.ghost?
end
end
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb
index 3deb86da6cf..73b6e74eaa0 100644
--- a/app/models/concerns/milestoneish.rb
+++ b/app/models/concerns/milestoneish.rb
@@ -66,7 +66,7 @@ module Milestoneish
end
def upcoming?
- start_date && start_date.future?
+ start_date&.future?
end
def expires_at
@@ -80,7 +80,7 @@ module Milestoneish
end
def expired?
- due_date && due_date.past?
+ due_date&.past?
end
def group_milestone?
diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb
index 3ff4b4046d3..efcf7c86ad5 100644
--- a/app/models/concerns/spammable.rb
+++ b/app/models/concerns/spammable.rb
@@ -26,7 +26,7 @@ module Spammable
end
def submittable_as_spam_by?(current_user)
- current_user && current_user.admin? && submittable_as_spam?
+ current_user&.admin? && submittable_as_spam?
end
def submittable_as_spam?
diff --git a/app/models/concerns/strip_attribute.rb b/app/models/concerns/strip_attribute.rb
index 8f6a6244dd3..1be24e3d57d 100644
--- a/app/models/concerns/strip_attribute.rb
+++ b/app/models/concerns/strip_attribute.rb
@@ -30,7 +30,7 @@ module StripAttribute
def strip_attributes
self.class.strip_attrs.each do |attr|
- self[attr].strip! if self[attr] && self[attr].respond_to?(:strip!)
+ self[attr].strip! if self[attr]&.respond_to?(:strip!)
end
end
end
diff --git a/app/models/group.rb b/app/models/group.rb
index 8e89c7ecfb1..fa752201d3c 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -155,7 +155,7 @@ class Group < Namespace
end
def visibility_level_allowed_by_parent?(level = self.visibility_level)
- return true unless parent_id && parent_id.nonzero?
+ return true unless parent_id&.nonzero?
level <= parent.visibility_level
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 30e29911758..bb0dc336191 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -208,7 +208,7 @@ class Issue < ApplicationRecord
# Returns `true` if the current issue can be viewed by either a logged in User
# or an anonymous user.
def visible_to_user?(user = nil)
- return false unless project && project.feature_available?(:issues, user)
+ return false unless project&.feature_available?(:issues, user)
return publicly_visible? unless user
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 82034f5946b..f1c41766015 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -930,7 +930,7 @@ class MergeRequest < ApplicationRecord
end
def source_project_namespace
- if source_project && source_project.namespace
+ if source_project&.namespace
source_project.namespace.full_path
else
"(removed)"
@@ -938,7 +938,7 @@ class MergeRequest < ApplicationRecord
end
def target_project_namespace
- if target_project && target_project.namespace
+ if target_project&.namespace
target_project.namespace.full_path
else
"(removed)"
@@ -1271,7 +1271,7 @@ class MergeRequest < ApplicationRecord
end
def has_complete_diff_refs?
- diff_refs && diff_refs.complete?
+ diff_refs&.complete?
end
# rubocop: disable CodeReuse/ServiceClass
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb
index f54497fc6d8..4cbd368d0bd 100644
--- a/app/models/project_services/issue_tracker_service.rb
+++ b/app/models/project_services/issue_tracker_service.rb
@@ -95,8 +95,7 @@ class IssueTrackerService < Service
private
def enabled_in_gitlab_config
- Gitlab.config.issues_tracker &&
- Gitlab.config.issues_tracker.values.any? &&
+ Gitlab.config.issues_tracker&.values&.any? &&
issues_tracker
end
diff --git a/app/models/ref_matcher.rb b/app/models/ref_matcher.rb
index fa7d2c0f06c..991b171bc7c 100644
--- a/app/models/ref_matcher.rb
+++ b/app/models/ref_matcher.rb
@@ -20,7 +20,7 @@ class RefMatcher
# Checks if this protected ref contains a wildcard
def wildcard?
- @ref_name_or_pattern && @ref_name_or_pattern.include?('*')
+ @ref_name_or_pattern&.include?('*')
end
protected
diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb
index 134de1c9ace..38cdacfd8a6 100644
--- a/app/policies/global_policy.rb
+++ b/app/policies/global_policy.rb
@@ -9,7 +9,7 @@ class GlobalPolicy < BasePolicy
with_options scope: :user, score: 0
condition(:access_locked) { @user&.access_locked? }
- condition(:can_create_fork, scope: :user) { @user && @user.manageable_namespaces.any? { |namespace| @user.can?(:create_projects, namespace) } }
+ condition(:can_create_fork, scope: :user) { @user&.manageable_namespaces&.any? { |namespace| @user.can?(:create_projects, namespace) } }
condition(:required_terms_not_accepted, scope: :user, score: 0) do
@user&.required_terms_not_accepted?
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb
index 8258135da4e..85d1ac370c6 100644
--- a/app/serializers/environment_entity.rb
+++ b/app/serializers/environment_entity.rb
@@ -55,7 +55,7 @@ class EnvironmentEntity < Grape::Entity
end
def cluster_platform_kubernetes?
- deployment_platform && deployment_platform.is_a?(Clusters::Platforms::Kubernetes)
+ deployment_platform&.is_a?(Clusters::Platforms::Kubernetes)
end
def deployment_platform
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 3f0aedfbfb2..3723fa98ab0 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -15,7 +15,7 @@ class CompareService
def execute(target_project, target_ref, base_sha: nil, straight: false)
raw_compare = target_project.repository.compare_source_branch(target_ref, start_project.repository, start_ref_name, straight: straight)
- return unless raw_compare && raw_compare.base && raw_compare.head
+ return unless raw_compare&.base && raw_compare.head
Compare.new(raw_compare,
target_project,
diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb
index 0066cd0491f..f8f1641a275 100644
--- a/app/services/merge_requests/update_service.rb
+++ b/app/services/merge_requests/update_service.rb
@@ -90,7 +90,7 @@ module MergeRequests
merge_request.update(merge_error: nil)
- if merge_request.head_pipeline && merge_request.head_pipeline.active?
+ if merge_request.head_pipeline&.active?
AutoMergeService.new(project, current_user).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS)
else
merge_request.merge_async(current_user.id, {})
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 9f335cceb67..9ea1b8f2f2a 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -65,7 +65,7 @@ module Projects
message = "Unable to save #{e.record.type}: #{e.record.errors.full_messages.join(", ")} "
fail(error: message)
rescue => e
- @project.errors.add(:base, e.message) if @project
+ @project&.errors&.add(:base, e.message)
fail(error: e.message)
end
@@ -153,7 +153,7 @@ module Projects
log_message << " Project ID: #{@project.id}" if @project&.id
Rails.logger.error(log_message)
- if @project && @project.persisted? && @project.import_state
+ if @project&.persisted? && @project.import_state
@project.import_state.mark_as_failed(message)
end
diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb
index 9af59b0aceb..307350e76d5 100644
--- a/app/uploaders/avatar_uploader.rb
+++ b/app/uploaders/avatar_uploader.rb
@@ -7,7 +7,7 @@ class AvatarUploader < GitlabUploader
prepend ObjectStorage::Extension::RecordsUploads
def exists?
- model.avatar.file && model.avatar.file.present?
+ model.avatar.file&.present?
end
def move_to_store
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index 0a44d60778d..6320700b038 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -438,7 +438,7 @@ module ObjectStorage
file
rescue => e
# in case of failure delete new file
- new_file.delete unless new_file.nil?
+ new_file&.delete
# revert back to the old file
self.object_store = from_object_store
self.file = file_to_delete
diff --git a/app/uploaders/records_uploads.rb b/app/uploaders/records_uploads.rb
index 00b51f92b12..08f83c84546 100644
--- a/app/uploaders/records_uploads.rb
+++ b/app/uploaders/records_uploads.rb
@@ -21,7 +21,7 @@ module RecordsUploads
# rubocop: disable CodeReuse/ActiveRecord
def record_upload(_tempfile = nil)
return unless model
- return unless file && file.exists?
+ return unless file&.exists?
# MySQL InnoDB may encounter a deadlock if a deletion and an
# insert is in the same transaction due to its next-key locking
@@ -36,7 +36,7 @@ module RecordsUploads
def readd_upload
uploads.where(path: upload_path).delete_all
- upload.delete if upload
+ upload&.delete
self.upload = build_upload.tap(&:save!)
end
@@ -73,7 +73,7 @@ module RecordsUploads
# Called `before :remove`
# rubocop: disable CodeReuse/ActiveRecord
def destroy_upload(*args)
- return unless file && file.exists?
+ return unless file&.exists?
self.upload = nil
uploads.where(path: upload_path).delete_all
diff --git a/app/validators/branch_filter_validator.rb b/app/validators/branch_filter_validator.rb
index 6a0899be850..039dafff98a 100644
--- a/app/validators/branch_filter_validator.rb
+++ b/app/validators/branch_filter_validator.rb
@@ -14,7 +14,7 @@
#
class BranchFilterValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- value.squish! unless value.nil?
+ value&.squish!
if value.present?
value_without_wildcards = value.tr('*', 'x')
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index dba7837bd12..2b9d8fe408e 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -50,8 +50,7 @@ class PostReceive
Git::BranchPushService
end
- if service_klass
- service_klass.new(
+ service_klass&.new(
post_received.project,
user,
oldrev: oldrev,
@@ -59,8 +58,7 @@ class PostReceive
ref: ref,
push_options: post_received.push_options,
create_pipelines: index < PIPELINE_PROCESS_LIMIT || Feature.enabled?(:git_push_create_all_pipelines, post_received.project)
- ).execute
- end
+ )&.execute
changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref)
refs << ref