From d8e354ec1b20b8626d4b96eaa5ae469199ceed26 Mon Sep 17 00:00:00 2001 From: Malaber Date: Wed, 6 May 2026 15:21:37 +0200 Subject: [PATCH] fix: allow CLI script output lint --- .rubocop.yml | 8 ++++++++ e2e/load_test.rb | 14 +++++--------- script/e2e_scenarios.rb | 8 ++------ script/wait_for_http.rb | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fc13361..8981d87 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -66,6 +66,14 @@ Rails/SkipsModelValidations: - "app/services/tournament_sync_pusher.rb" - "db/migrate/**/*" +# These are standalone CLI entrypoints where stdout is command output, +# not Rails application logging. +Rails/Output: + Exclude: + - "e2e/load_test.rb" + - "script/e2e_scenarios.rb" + - "script/wait_for_http.rb" + Rails/Delegate: Exclude: - "app/controllers/tournaments_controller.rb" diff --git a/e2e/load_test.rb b/e2e/load_test.rb index c32400a..def4057 100755 --- a/e2e/load_test.rb +++ b/e2e/load_test.rb @@ -6,10 +6,6 @@ require 'optparse' require_relative 'lib/load_test_runner' -def write_line(message = '') - $stdout.write("#{message}\n") -end - def parse_client_list(value) return [] if value.nil? || value.strip == '' || value.strip.casecmp('none').zero? @@ -76,12 +72,12 @@ runner = TurniereE2E::LoadTestRunner.new(**runner_options) result = runner.run if options[:format] == 'json' - write_line JSON.pretty_generate(result) + puts JSON.pretty_generate(result) else - write_line "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}" + puts "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}" result.fetch(:http).each do |level| - write_line( + puts( "HTTP #{level.fetch(:clients)} clients: " \ "#{level.fetch(:ok)}/#{level.fetch(:requests)} ok, errors=#{level.fetch(:errors)}, " \ "p50=#{level.fetch(:p50_ms)}ms, p95=#{level.fetch(:p95_ms)}ms, " \ @@ -90,7 +86,7 @@ else end result.fetch(:websocket).each do |level| - write_line( + puts( "WS #{level.fetch(:clients)} clients: " \ "opened=#{level.fetch(:opened)}, errors=#{level.fetch(:errors)}, " \ "p50_open=#{level.fetch(:p50_open_ms)}ms, p95_open=#{level.fetch(:p95_open_ms)}ms, " \ @@ -99,7 +95,7 @@ else end metrics = result.fetch(:metrics) - write_line( + puts( "Metrics: action_cable_connections=#{metrics.fetch(:action_cable_connections)}, " \ "action_cable_connections_total=#{metrics.fetch(:action_cable_connections_total)}, " \ "ruby_threads=#{metrics.fetch(:ruby_threads)}" diff --git a/script/e2e_scenarios.rb b/script/e2e_scenarios.rb index 238ea05..c35102b 100755 --- a/script/e2e_scenarios.rb +++ b/script/e2e_scenarios.rb @@ -5,12 +5,8 @@ require 'json' require 'optparse' require_relative '../e2e/lib/scenario_runner' -def write_line(message) - $stdout.write("#{message}\n") -end - def fail_with(message) - $stderr.write("#{message}\n") + warn message raise SystemExit, 1 end @@ -78,4 +74,4 @@ result = case scenario fail_with("Unknown scenario #{scenario.inspect}") end -write_line JSON.pretty_generate(result) +puts JSON.pretty_generate(result) diff --git a/script/wait_for_http.rb b/script/wait_for_http.rb index dad5f0d..1513de2 100755 --- a/script/wait_for_http.rb +++ b/script/wait_for_http.rb @@ -8,4 +8,4 @@ timeout = (ARGV[1] || 30).to_i runner = TurniereE2E::ScenarioRunner.new(base_url: url) runner.wait_for_healthcheck!(timeout_seconds: timeout) -$stdout.write("ready: #{url}\n") +puts "ready: #{url}"