Commit e39972b7 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'resolve-class-equality-comparison' into 'master'

Resolve Style/ClassEqualityComparison exceptions

See merge request gitlab-org/gitlab!65357
parents 64779a74 154e0bad
......@@ -2146,11 +2146,6 @@ Gitlab/NamespacedClass:
- 'spec/tasks/gitlab/task_helpers_spec.rb'
- 'spec/uploaders/object_storage_spec.rb'
Style/ClassEqualityComparison:
Exclude:
- spec/lib/peek/views/active_record_spec.rb
- ee/spec/lib/peek/views/active_record_spec.rb
# WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/207950
Cop/UserAdmin:
Exclude:
......
......@@ -660,23 +660,6 @@ Style/BisectedAttrAccessor:
Style/CaseLikeIf:
Enabled: false
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: ==, equal?, eql?
Style/ClassEqualityComparison:
Exclude:
- 'app/finders/security/jobs_finder.rb'
- 'app/services/projects/overwrite_project_service.rb'
- 'app/uploaders/dependency_proxy/file_uploader.rb'
- 'ee/app/graphql/resolvers/vulnerabilities/issue_links_resolver.rb'
- 'lib/gitlab/background_migration/user_mentions/models/note.rb'
- 'lib/gitlab/diff/file.rb'
- 'lib/gitlab/git.rb'
- 'lib/gitlab/import_export/relation_tree_restorer.rb'
- 'spec/requests/api/services_spec.rb'
- 'spec/support/shared_examples/lib/gitlab/import_export/relation_factory_shared_examples.rb'
# Offense count: 13
Style/CombinableLoops:
Exclude:
......
......@@ -20,7 +20,7 @@ module Security
end
def initialize(pipeline:, job_types: [])
if self.class == Security::JobsFinder
if self.instance_of?(Security::JobsFinder)
raise NotImplementedError, 'This is an abstract class, please instantiate its descendants'
end
......
......@@ -20,7 +20,7 @@ module Projects
rescue Exception => e # rubocop:disable Lint/RescueException
attempt_restore_repositories(source_project)
if e.class == Exception
if e.instance_of?(Exception)
raise StandardError, e.message
else
raise
......
......@@ -24,7 +24,7 @@ class DependencyProxy::FileUploader < GitlabUploader
# so we must store the custom content type in object storage.
# This does not apply to DependencyProxy::Blob uploads.
def set_content_type(file)
return unless model.class == DependencyProxy::Manifest
return unless model.instance_of?(DependencyProxy::Manifest)
file.content_type = model.content_type
end
......
......@@ -35,7 +35,7 @@ module Resolvers
end
def valid_link_type?(args)
if args[:link_type].class == String
if args[:link_type].instance_of?(String)
link_type = args[:link_type].downcase
link_types = ::Vulnerabilities::IssueLink.link_types.keys
......
......@@ -21,7 +21,7 @@ module Gitlab
belongs_to :project, class_name: "::Gitlab::BackgroundMigration::UserMentions::Models::Project"
def for_personal_snippet?
noteable && noteable.class.name == 'PersonalSnippet'
noteable && noteable.instance_of?(PersonalSnippet)
end
def for_project_noteable?
......
......@@ -449,7 +449,7 @@ module Gitlab
end
def alternate_viewer_class
return unless viewer.class == DiffViewer::Renamed
return unless viewer.instance_of?(DiffViewer::Renamed)
find_renderable_viewer_class(RICH_VIEWERS) || (DiffViewer::Text if text?)
end
......
......@@ -80,7 +80,7 @@ module Gitlab
def shas_eql?(sha1, sha2)
return true if sha1.nil? && sha2.nil?
return false if sha1.nil? || sha2.nil?
return false unless sha1.class == sha2.class
return false unless sha1.instance_of?(sha2.class)
# If either of the shas is below the minimum length, we cannot be sure
# that they actually refer to the same commit because of hash collision.
......
......@@ -37,7 +37,7 @@ module Gitlab
ActiveRecord::Base.no_touching do
update_params!
BulkInsertableAssociations.with_bulk_insert(enabled: @importable.class == ::Project) do
BulkInsertableAssociations.with_bulk_insert(enabled: @importable.instance_of?(::Project)) do
fix_ci_pipelines_not_sorted_on_legacy_project_json!
create_relations!
end
......
......@@ -76,7 +76,7 @@ RSpec.describe API::Services do
required_attributes = service_attrs_list.select do |attr|
service_klass.validators_on(attr).any? do |v|
v.class == ActiveRecord::Validations::PresenceValidator &&
v.instance_of?(ActiveRecord::Validations::PresenceValidator) &&
# exclude presence validators with conditional since those are not really required
![:if, :unless].any? { |cond| v.options.include?(cond) }
end
......
......@@ -12,7 +12,7 @@ RSpec.shared_examples 'Notes user references' do
'id' => 111,
'access_level' => 30,
'source_id' => 1,
'source_type' => importable.class.name == 'Project' ? 'Project' : 'Namespace',
'source_type' => importable.instance_of?(Project) ? 'Project' : 'Namespace',
'user_id' => 3,
'notification_level' => 3,
'created_at' => '2016-11-18T09:29:42.634Z',
......
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