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
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
- #on_block(node) ⇒ Object (also: #on_numblock)
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
44 45 46 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 44 def on_block(node) check(node) end |
#on_send(node) ⇒ Object Also known as: on_csend
39 40 41 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 39 def on_send(node) check(node) end |