Skip to content

Commit

Permalink
rubocop: fix the Performance/TimesMap cop offenses
Browse files Browse the repository at this point in the history
It's a new cop introduced by
rubocop/rubocop#2583
  • Loading branch information
kyrylo committed Jan 18, 2016
1 parent 53134c8 commit f69d12c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
Performance/TimesMap:
Exclude:
- 'benchmarks/payload_truncator.rb'
- 'benchmarks/payload_truncator_string_encoding.rb'

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/payload_truncator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# Generates example errors that should be truncated.
class Payload
def self.generate
5000.times.map do |i|
Array.new(5000) do |i|
{ type: "Error#{i}",
message: 'X' * 300,
backtrace: 300.times.map { 'Y' * 300 } }
backtrace: Array.new(300) { 'Y' * 300 } }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/payload_truncator_string_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def mixed
part = MAX / methods.size

methods.each do |method|
strings << part.times.map { StringGenerator.__send__(method) }
strings << Array.new(part) { StringGenerator.__send__(method) }
end

strings.flatten
Expand All @@ -89,7 +89,7 @@ def best
private

def generate(&block)
MAX.times.map(&block)
Array.new(MAX, &block)
end
end
end
Expand Down

0 comments on commit f69d12c

Please sign in to comment.