Commit b4c2a3375926edb0346ac2702a36918d5f6f1dc9

Authored by Laust Rud Jacobsen
1 parent f6bea424
Exists in master and in 1 other branch production

Rubocop: minor performance change: use Array.sample over Array.shuffle.first

.rubocop_todo.yml
... ... @@ -35,13 +35,6 @@ Metrics/PerceivedComplexity:
35 35  
36 36 # Offense count: 2
37 37 # Cop supports --auto-correct.
38   -Performance/Sample:
39   - Exclude:
40   - - 'lib/tasks/errbit/demo.rake'
41   - - 'spec/fabricators/backtrace_fabricator.rb'
42   -
43   -# Offense count: 2
44   -# Cop supports --auto-correct.
45 38 Performance/StringReplacement:
46 39 Exclude:
47 40 - 'app/models/notification_services/gtalk_service.rb'
... ...
lib/tasks/errbit/demo.rake
... ... @@ -35,7 +35,7 @@ namespace :errbit do
35 35 99.times {|t| backtrace << {
36 36 'number' => t.hash % 1000,
37 37 'file' => "/path/to/file.rb",
38   - 'method' => RANDOM_METHODS.shuffle.first.to_s
  38 + 'method' => RANDOM_METHODS.sample.to_s
39 39 }}
40 40 backtrace
41 41 end
... ...
spec/fabricators/backtrace_fabricator.rb
... ... @@ -3,7 +3,7 @@ Fabricator :backtrace do
3 3 {
4 4 number: rand(999),
5 5 file: "/path/to/file/#{SecureRandom.hex(4)}.rb",
6   - method: ActiveSupport.methods.shuffle.first
  6 + method: ActiveSupport.methods.sample
7 7 }
8 8 end
9 9 end
... ...