Class: RuboCop::Cop::Performance::TimesMap
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Performance::TimesMap
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/performance/times_map.rb
Overview
This cop checks for .times.map calls. In most cases such calls can be replaced with an explicit array creation.
Constant Summary collapse
- MESSAGE =
'Use `Array.new(%<count>s)` with a block ' \ 'instead of `.times.%<map_or_collect>s`'
- MESSAGE_ONLY_IF =
'only if `%<count>s` is always 0 or more'- RESTRICT_ON_SEND =
%i[map collect].freeze
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
44 45 46 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 44 def on_block(node) check(node) end |
#on_send(node) ⇒ Object
40 41 42 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 40 def on_send(node) check(node) end |