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_itblock)
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock, on_itblock
51 52 53 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 51 def on_block(node) check(node) end |
#on_send(node) ⇒ Object Also known as: on_csend
46 47 48 |
# File 'lib/rubocop/cop/performance/times_map.rb', line 46 def on_send(node) check(node) end |