Commit 741400a0 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'pl-rubocop-todo-redundant-safe-navigation' into 'master'

Resolves rubocop offense Lint/RedundantSafeNavigation

See merge request gitlab-org/gitlab!56884
parents aa45e550 17deaaff
......@@ -184,21 +184,6 @@ Lint/MixedRegexpCaptureTypes:
Lint/RedundantCopDisableDirective:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: AllowedMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
Lint/RedundantSafeNavigation:
Exclude:
- 'app/controllers/concerns/labels_as_hash.rb'
- 'app/policies/note_policy.rb'
- 'app/services/users/update_canonical_email_service.rb'
- 'ee/app/presenters/iteration_presenter.rb'
- 'ee/app/services/ee/members/destroy_service.rb'
- 'ee/lib/ee/gitlab/email/handler/reply_processing.rb'
- 'qa/qa/specs/helpers/quarantine.rb'
- 'spec/controllers/boards/issues_controller_spec.rb'
# Offense count: 1
Lint/SelfAssignment:
Exclude:
......
......@@ -11,7 +11,7 @@ module LabelsAsHash
label_hashes = available_labels.as_json(only: [:title, :color])
if target&.respond_to?(:labels)
if target.respond_to?(:labels)
already_set_labels = available_labels & target.labels
if already_set_labels.present?
titles = already_set_labels.map(&:title)
......
......@@ -76,7 +76,7 @@ class NotePolicy < BasePolicy
def parent_namespace
strong_memoize(:parent_namespace) do
next if @subject.is_a?(PersonalSnippet)
next @subject.noteable.group if @subject.noteable&.is_a?(Epic)
next @subject.noteable.group if @subject.noteable.is_a?(Epic)
@subject.project
end
......
......@@ -7,7 +7,7 @@ module Users
INCLUDED_DOMAINS_PATTERN = [/gmail.com/].freeze
def initialize(user:)
raise ArgumentError.new("Please provide a user") unless user&.is_a?(User)
raise ArgumentError.new("Please provide a user") unless user.is_a?(User)
@user = user
end
......
---
title: Fixes offense Lint/RedundantSafeNavigation
merge_request: 56884
author: Shubham Kumar (@imskr)
type: fixed
......@@ -14,7 +14,7 @@ class IterationPresenter < Gitlab::View::Presenter::Delegated
def scoped_iteration_path(parent:)
parent_object = parent[:parent_object] || iteration.resource_parent
if parent_object&.is_a?(Project)
if parent_object.is_a?(Project)
project_iteration_path(parent_object, iteration.id, only_path: true)
else
group_iteration_path(parent_object, iteration.id, only_path: true)
......@@ -24,7 +24,7 @@ class IterationPresenter < Gitlab::View::Presenter::Delegated
def scoped_iteration_url(parent:)
parent_object = parent[:parent_object] || iteration.resource_parent
if parent_object&.is_a?(Project)
if parent_object.is_a?(Project)
project_iteration_url(parent_object, iteration.id)
else
group_iteration_url(parent_object, iteration.id)
......
......@@ -13,7 +13,7 @@ module EE
end
cleanup_group_identity(member)
cleanup_group_deletion_schedule(member) if member.source&.is_a?(Group)
cleanup_group_deletion_schedule(member) if member.source.is_a?(Group)
end
private
......
......@@ -11,7 +11,7 @@ module EE
override :upload_params
def upload_params
return super unless try(:noteable)&.is_a?(Epic)
return super unless try(:noteable).is_a?(Epic)
{
upload_parent: noteable.group,
......
......@@ -52,7 +52,7 @@ module QA
if example.metadata.key?(:quarantine)
quarantine_tag = example.metadata[:quarantine]
if quarantine_tag&.is_a?(Hash) && quarantine_tag&.key?(:only)
if quarantine_tag.is_a?(Hash) && quarantine_tag&.key?(:only)
# If the :quarantine hash contains :only, we respect that.
# For instance `quarantine: { only: { subdomain: :staging } }` will only quarantine the test when it runs against staging.
return unless Runtime::Env.context_matches?(quarantine_tag[:only])
......
......@@ -404,7 +404,7 @@ RSpec.describe Boards::IssuesController do
list_id: list.try(:to_param)
}
unless board.try(:parent)&.is_a?(Group)
unless board.try(:parent).is_a?(Group)
params[:namespace_id] = project.namespace.to_param
params[:project_id] = project
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