Class: RuboCop::Cop::Performance::ConcurrentMonotonicTime
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
AutoCorrector,
Base
|
|
Instance Chain:
self,
Base
|
|
Inherits: |
Base
|
Defined in: | lib/rubocop/cop/performance/concurrent_monotonic_time.rb |
Overview
Identifies places where Concurrent.monotonic_time
can be replaced by Process.clock_gettime(Process::CLOCK_MONOTONIC)
.
Constant Summary
-
MSG =
# File 'lib/rubocop/cop/performance/concurrent_monotonic_time.rb', line 20'Use `%<prefer>s` instead of `%<current>s`.'
-
RESTRICT_ON_SEND =
# File 'lib/rubocop/cop/performance/concurrent_monotonic_time.rb', line 21%i[monotonic_time].freeze
Instance Method Summary
Instance Method Details
#on_send(node)
[ GitHub ]# File 'lib/rubocop/cop/performance/concurrent_monotonic_time.rb', line 28
def on_send(node) return unless concurrent_monotonic_time?(node) optional_unit_parameter = ", #{node.first_argument.source}" if node.first_argument prefer = "Process.clock_gettime(Process::CLOCK_MONOTONIC#{optional_unit_parameter})" = format(MSG, prefer: prefer, current: node.source) add_offense(node, message: ) do |corrector| corrector.replace(node, prefer) end end