Commit b4c2a3375926edb0346ac2702a36918d5f6f1dc9
1 parent
f6bea424
Exists in
master
and in
1 other branch
Rubocop: minor performance change: use Array.sample over Array.shuffle.first
Showing
3 changed files
with
2 additions
and
9 deletions
Show diff stats
.rubocop_todo.yml
| @@ -35,13 +35,6 @@ Metrics/PerceivedComplexity: | @@ -35,13 +35,6 @@ Metrics/PerceivedComplexity: | ||
| 35 | 35 | ||
| 36 | # Offense count: 2 | 36 | # Offense count: 2 |
| 37 | # Cop supports --auto-correct. | 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 | Performance/StringReplacement: | 38 | Performance/StringReplacement: |
| 46 | Exclude: | 39 | Exclude: |
| 47 | - 'app/models/notification_services/gtalk_service.rb' | 40 | - 'app/models/notification_services/gtalk_service.rb' |
lib/tasks/errbit/demo.rake
| @@ -35,7 +35,7 @@ namespace :errbit do | @@ -35,7 +35,7 @@ namespace :errbit do | ||
| 35 | 99.times {|t| backtrace << { | 35 | 99.times {|t| backtrace << { |
| 36 | 'number' => t.hash % 1000, | 36 | 'number' => t.hash % 1000, |
| 37 | 'file' => "/path/to/file.rb", | 37 | 'file' => "/path/to/file.rb", |
| 38 | - 'method' => RANDOM_METHODS.shuffle.first.to_s | 38 | + 'method' => RANDOM_METHODS.sample.to_s |
| 39 | }} | 39 | }} |
| 40 | backtrace | 40 | backtrace |
| 41 | end | 41 | end |
spec/fabricators/backtrace_fabricator.rb
| @@ -3,7 +3,7 @@ Fabricator :backtrace do | @@ -3,7 +3,7 @@ Fabricator :backtrace do | ||
| 3 | { | 3 | { |
| 4 | number: rand(999), | 4 | number: rand(999), |
| 5 | file: "/path/to/file/#{SecureRandom.hex(4)}.rb", | 5 | file: "/path/to/file/#{SecureRandom.hex(4)}.rb", |
| 6 | - method: ActiveSupport.methods.shuffle.first | 6 | + method: ActiveSupport.methods.sample |
| 7 | } | 7 | } |
| 8 | end | 8 | end |
| 9 | end | 9 | end |