Class: RuboCop::Cop::Isucon::Sinatra::Logger

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/isucon/sinatra/logger.rb

Overview

Disable sinatra logger logging

Examples:

# bad
logger.error "Search condition not found"

# good
# no logging

Constant Summary collapse

MSG =
"Don't use `logger`"

Instance Method Summary collapse

Instance Method Details

#logger?(node) ⇒ Boolean

Parameters:

  • node (RuboCop::AST::Node)

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/rubocop/cop/isucon/sinatra/logger.rb', line 24

def_node_matcher :logger?, <<~PATTERN
  (send
    (send nil? :logger)
    {:debug | :error | :fatal | :info | :warn}
    ...
  )
PATTERN

#on_send(node) ⇒ Object

Parameters:

  • node (RuboCop::AST::Node)


33
34
35
36
37
38
39
# File 'lib/rubocop/cop/isucon/sinatra/logger.rb', line 33

def on_send(node)
  return unless logger?(node)

  add_offense(node) do |corrector|
    perform_autocorrect(corrector: corrector, node: node)
  end
end