Class: RuboCop::Cop::Isucon::Sinatra::ServeStaticFile
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Isucon::Sinatra::ServeStaticFile
show all
- Includes:
- Mixin::SinatraMethods
- Defined in:
- lib/rubocop/cop/isucon/sinatra/serve_static_file.rb
Overview
Serve static files on front server (e.g. nginx) instead of sinatra app
Constant Summary
collapse
- MSG =
"Serve static files on front server (e.g. nginx) instead of sinatra app"
Instance Method Summary
collapse
#parent_is_sinatra_app?, #subclass_of_sinatra_base?, #subclass_of_sinatra_base_contains_logging?
Instance Method Details
#file_read_method?(node) ⇒ Boolean
31
32
33
|
# File 'lib/rubocop/cop/isucon/sinatra/serve_static_file.rb', line 31
def_node_matcher :file_read_method?, <<~PATTERN
(send (const nil? :File) :read ...)
PATTERN
|
#get_block?(node) ⇒ Boolean
38
39
40
|
# File 'lib/rubocop/cop/isucon/sinatra/serve_static_file.rb', line 38
def_node_matcher :get_block?, <<~PATTERN
(block (send nil? :get ...) ...)
PATTERN
|
#on_send(node) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rubocop/cop/isucon/sinatra/serve_static_file.rb', line 43
def on_send(node)
return unless parent_is_sinatra_app?(node)
return unless file_read_method?(node)
parent = parent_get_node(node)
return unless parent
return unless end_of_block?(node: node, parent: parent)
add_offense(parent)
end
|