diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-24 11:11:18 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-24 11:47:58 -0700 |
commit | 3e001d29ccdb5a5b1ba223710525f8dc7ae844ee (patch) | |
tree | 5046754a8858795a02043a743e18fb8b05610f41 /app/models/note.rb | |
parent | 0d538e44aff066372ecd9d10ac6786681bc347c9 (diff) | |
download | gitlab-ce-sh-enable-rubocop-hash-search.tar.gz |
Enable Rubocop Performance/InefficientHashSearchsh-enable-rubocop-hash-search
When used with a Hash, `.keys.include?` is bad because:
1. It performs a O(n) search instead of the efficient `.has_key?`
2. It clones all keys into separate array.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64975
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 5c31cff9816..3f182c1f099 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -292,7 +292,7 @@ class Note < ApplicationRecord end 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 end |