From 6ad16f186207d5b9e1566a9eac81a5b8b9bac431 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Sun, 25 Aug 2024 21:17:35 +0300 Subject: [PATCH] linting --- lib/react_on_rails/helper.rb | 5 +++-- .../ruby_embedded_java_script.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 0a01b7722..46a5b59fa 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -436,7 +436,7 @@ def build_react_component_result_for_server_streamed_content( render_options: required("render_options") ) is_first_chunk = true - rendered_html_stream = rendered_html_stream.transform do |chunk_json_result| + rendered_html_stream.transform do |chunk_json_result| if is_first_chunk is_first_chunk = false next build_react_component_result_for_server_rendered_string( @@ -448,7 +448,8 @@ def build_react_component_result_for_server_streamed_content( end result_console_script = render_options.replay_console ? chunk_json_result["consoleReplayScript"] : "" - # No need to prepend component_specification_tag or add rails context again as they're already included in the first chunk + # No need to prepend component_specification_tag or add rails context again + # as they're already included in the first chunk compose_react_component_html_with_spec_and_console( "", chunk_json_result["html"], result_console_script ) diff --git a/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb b/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb index 3b03b21ae..d1136c231 100644 --- a/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +++ b/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb @@ -46,7 +46,7 @@ def reset_pool_if_server_bundle_was_modified # Note, js_code does not have to be based on React. # js_code MUST RETURN json stringify Object # Calling code will probably call 'html_safe' on return value before rendering to the view. - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:disable Metrics/CyclomaticComplexity def exec_server_render_js(js_code, render_options, js_evaluator = nil) js_evaluator ||= self if render_options.trace @@ -57,10 +57,10 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil) end begin result = if render_options.stream? - js_evaluator.eval_streaming_js(js_code, render_options) - else - js_evaluator.eval_js(js_code, render_options) - end + js_evaluator.eval_streaming_js(js_code, render_options) + else + js_evaluator.eval_js(js_code, render_options) + end rescue StandardError => err msg = <<~MSG Error evaluating server bundle. Check your webpack configuration. @@ -75,14 +75,14 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil) end raise ReactOnRails::Error, msg, err.backtrace end - + return parse_result_and_replay_console_messages(result, render_options) unless render_options.stream? # Streamed component is returned as stream of strings. # We need to parse each chunk and replay the console messages. result.transform { |chunk| parse_result_and_replay_console_messages(chunk, render_options) } end - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:enable Metrics/CyclomaticComplexity def trace_js_code_used(msg, js_code, file_name = "tmp/server-generated.js", force: false) return unless ReactOnRails.configuration.trace || force