Class: RuboCop::Cop::Isucon::Sinatra::DisableLogging
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Isucon::Sinatra::DisableLogging
show all
- Extended by:
- AutoCorrector
- Includes:
- Mixin::SinatraMethods
- Defined in:
- lib/rubocop/cop/isucon/sinatra/disable_logging.rb
Overview
Constant Summary
collapse
- MSG =
"Disable sinatra logging."
Instance Method Summary
collapse
#parent_is_sinatra_app?, #subclass_of_sinatra_base?, #subclass_of_sinatra_base_contains_logging?
Instance Method Details
#logging_enabled?(node) ⇒ Boolean
34
35
36
|
# File 'lib/rubocop/cop/isucon/sinatra/disable_logging.rb', line 34
def_node_matcher :logging_enabled?, <<~PATTERN
(send nil? :enable (sym :logging))
PATTERN
|
#on_class(node) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/rubocop/cop/isucon/sinatra/disable_logging.rb', line 49
def on_class(node)
return unless subclass_of_sinatra_base?(node)
return if subclass_of_sinatra_base_contains_logging?(node)
add_offense(node) do |corrector|
perform_autocorrect_for_on_class(corrector: corrector, node: node)
end
end
|
#on_send(node) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/rubocop/cop/isucon/sinatra/disable_logging.rb', line 39
def on_send(node)
return unless parent_is_sinatra_app?(node)
return unless logging_enabled?(node)
add_offense(node) do |corrector|
perform_autocorrect_for_on_send(corrector: corrector, node: node)
end
end
|