Class: RuboCop::Cop::Performance::FluentdPluginLogStringInterpolation
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Performance::FluentdPluginLogStringInterpolation
- Defined in:
- lib/rubocop/cop/performance/plugin_log_string_interpolation.rb
Overview
Constant Summary collapse
- RESTRICT_ON_SEND =
%i[trace debug info warn error fatal].freeze
Instance Method Summary collapse
- #log_message_string_interpolation?(node) ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#log_message_string_interpolation?(node) ⇒ Object
19 20 21 |
# File 'lib/rubocop/cop/performance/plugin_log_string_interpolation.rb', line 19 def_node_matcher :log_message_string_interpolation?, <<~PATTERN (send (send nil? :log) _ (dstr ...)) PATTERN |
#on_send(node) ⇒ Object Also known as: on_csend
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/performance/plugin_log_string_interpolation.rb', line 23 def on_send(node) # match log.debug("#{...}") and so on return unless (node) method = node.children[1].to_s msg = %Q(Use log.#{method} { "..." } instead of log.#{method}("...")) add_offense(node, message: msg) # mark do not match on_send further more ignore_node(node) end |