Class: RuboCop::Cop::Netlify::RequestTestsParamEncoding
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Netlify::RequestTestsParamEncoding
- Defined in:
- lib/rubocop/cop/netlify/request_tests_param_encoding.rb
Overview
This cop enforces the test to use ‘as:` option for encoding the request with a content type.
Constant Summary collapse
- MSG =
"%<http_method>s with params should be used with as: to specify a param encoding"
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/netlify/request_tests_param_encoding.rb', line 30 def on_send(node) request_method(node) do |http_method, option_pairs| params = option_pairs.detect { |pair| has_params?(pair) } as = option_pairs.detect { |pair| has_as?(pair) } if params && !as = format(MSG, http_method: http_method) add_offense(node, message: ) end end end |