diff --git a/CHANGELOG.md b/CHANGELOG.md index b716f8f..be01d2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## HEAD (unreleased) +- Reduce timeout to 1 second (https://github.com/zombocom/dead_end/pull/79) - Logically consecutive lines (such as chained methods are now joined) (https://github.com/zombocom/dead_end/pull/78) - Output improvement for cases where the only line is an single `end` (https://github.com/zombocom/dead_end/pull/78) diff --git a/lib/dead_end/internals.rb b/lib/dead_end/internals.rb index 6a79845..8dd1baf 100644 --- a/lib/dead_end/internals.rb +++ b/lib/dead_end/internals.rb @@ -14,7 +14,7 @@ module DeadEnd class Error < StandardError; end SEARCH_SOURCE_ON_ERROR_DEFAULT = true - TIMEOUT_DEFAULT = ENV.fetch("DEAD_END_TIMEOUT", 5).to_i + TIMEOUT_DEFAULT = ENV.fetch("DEAD_END_TIMEOUT", 1).to_i def self.handle_error(e, search_source_on_error: SEARCH_SOURCE_ON_ERROR_DEFAULT) raise e unless e.message.include?("end-of-input") diff --git a/spec/integration/improvement_regression_spec.rb b/spec/integration/improvement_regression_spec.rb index 6934756..07423b5 100644 --- a/spec/integration/improvement_regression_spec.rb +++ b/spec/integration/improvement_regression_spec.rb @@ -4,6 +4,25 @@ module DeadEnd RSpec.describe "Library only integration to test regressions and improvements" do + it "returns good results on routes.rb" do + source = fixtures_dir.join("routes.rb.txt").read + + io = StringIO.new + DeadEnd.call( + io: io, + source: source, + filename: "none" + ) + + expect(io.string).to include(<<~'EOM'.indent(4)) + 1 Rails.application.routes.draw do + ❯ 113 namespace :admin do + ❯ 116 match "/foobar(*path)", via: :all, to: redirect { |_params, req| + ❯ 120 } + 121 end + EOM + end + it "handles multi-line-methods issues/64" do source = fixtures_dir.join("webmock.rb.txt").read diff --git a/spec/perf/perf_spec.rb b/spec/perf/perf_spec.rb deleted file mode 100644 index 221d5ba..0000000 --- a/spec/perf/perf_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require_relative "../spec_helper" -require "benchmark" - -module DeadEnd - RSpec.describe "perf" do - it "doesnt timeout" do - source = fixtures_dir.join("routes.rb.txt").read - - io = StringIO.new - bench = Benchmark.measure do - DeadEnd.call( - io: io, - source: source, - filename: "none" - ) - end - - expect(io.string).to include(<<~'EOM'.indent(4)) - 1 Rails.application.routes.draw do - ❯ 113 namespace :admin do - ❯ 116 match "/foobar(*path)", via: :all, to: redirect { |_params, req| - ❯ 120 } - 121 end - EOM - - expect(bench.real).to be < 1 # second - end - end -end