Commit 35ec674e authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-enable-rubocop-hash-search' into 'master'

Enable Rubocop Performance/InefficientHashSearch

Closes #64975

See merge request gitlab-org/gitlab-ce!31117
parents feb07ce0 3e001d29
...@@ -262,17 +262,6 @@ Naming/HeredocDelimiterNaming: ...@@ -262,17 +262,6 @@ Naming/HeredocDelimiterNaming:
Naming/RescuedExceptionsVariableName: Naming/RescuedExceptionsVariableName:
Enabled: false Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
Performance/InefficientHashSearch:
Exclude:
- 'app/controllers/concerns/sessionless_authentication.rb'
- 'app/models/note.rb'
- 'app/models/user_preference.rb'
- 'ee/app/models/ee/project.rb'
- 'lib/gitlab/import_export/members_mapper.rb'
- 'qa/spec/spec_helper.rb'
# Offense count: 3 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
Performance/ReverseEach: Performance/ReverseEach:
......
...@@ -13,7 +13,7 @@ module SessionlessAuthentication ...@@ -13,7 +13,7 @@ module SessionlessAuthentication
end end
def sessionless_user? def sessionless_user?
current_user && !session.keys.include?('warden.user.user.key') current_user && !session.key?('warden.user.user.key')
end end
def sessionless_sign_in(user) def sessionless_sign_in(user)
......
...@@ -292,7 +292,7 @@ class Note < ApplicationRecord ...@@ -292,7 +292,7 @@ class Note < ApplicationRecord
end end
def special_role=(role) def special_role=(role)
raise "Role is undefined, #{role} not found in #{SpecialRole.values}" unless SpecialRole.values.include?(role) raise "Role is undefined, #{role} not found in #{SpecialRole.values}" unless SpecialRole.value?(role)
@special_role = role @special_role = role
end end
......
...@@ -26,7 +26,7 @@ class UserPreference < ApplicationRecord ...@@ -26,7 +26,7 @@ class UserPreference < ApplicationRecord
def set_notes_filter(filter_id, issuable) def set_notes_filter(filter_id, issuable)
# No need to update the column if the value is already set. # No need to update the column if the value is already set.
if filter_id && NOTES_FILTERS.values.include?(filter_id) if filter_id && NOTES_FILTERS.value?(filter_id)
field = notes_filter_field_for(issuable) field = notes_filter_field_for(issuable)
self[field] = filter_id self[field] = filter_id
......
...@@ -46,7 +46,7 @@ RSpec.configure do |config| ...@@ -46,7 +46,7 @@ RSpec.configure do |config|
if ENV['CI'] if ENV['CI']
config.around do |example| config.around do |example|
retry_times = example.metadata.keys.include?(:quarantine) ? 1 : 2 retry_times = example.metadata.key?(:quarantine) ? 1 : 2
example.run_with_retry retry: retry_times example.run_with_retry retry: retry_times
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