dead_end 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f04f0b2618c6787e30d722b387fe19eb026923d588abf15d676566a3496970f7
4
- data.tar.gz: 9ea352efa6c3622eb9097a33f79db08219e4d156ea5ccbcfab3777e8e176472e
3
+ metadata.gz: 91a09272a46d3519c0ca78dcd3fd38199898fea1d6261c18576ff832e55351bd
4
+ data.tar.gz: f50e76a749fe0ecdf871fdaf6aead25132cb26a5d03068cbc611476c6eb06a8c
5
5
  SHA512:
6
- metadata.gz: 1dd513cdeba2f2e560eacd2113660e77f3eea9c0f0947629fe5c0e7352d2fcbf2178107fead38d7e7a32ead25e803b324809863af151eff70fb9831ffd43c8ec
7
- data.tar.gz: e377f56853a8fd6e72afd9bb262965876dfa0242158a7a7327523825a3e1c008173bf1c2d6b1bf25b5a79c51711326e6cae098cfe4b363407929ccbf7ae8ad78
6
+ metadata.gz: 89e7c7734a7a74c735479d35418ffda7d53557ce7d0c8a47fb2a67f5581d87d1be8117ff62d6590ed2cbf633fb566b797a6f3c3033e6c6a50b543cfbba9f4718
7
+ data.tar.gz: 2804e68394e928f36803859eb0e193bf96dc088138c4fea87510d6bc0d70e9c5485b6ca4c402762174c1ba3b139b9a4d1af28a6b31e87ec4e36859f659afc42d
@@ -1,5 +1,9 @@
1
1
  ## HEAD (unreleased)
2
2
 
3
+ ## 1.0.1
4
+
5
+ - Fix performance issue when evaluating multiple block combinations (https://github.com/zombocom/dead_end/pull/35)
6
+
3
7
  ## 1.0.0
4
8
 
5
9
  - Gem name changed from `syntax_search` to `dead_end` (https://github.com/zombocom/syntax_search/pull/30)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dead_end (1.0.0)
4
+ dead_end (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -153,11 +153,20 @@ module DeadEnd
153
153
  self.scan_while {|line| line.not_empty? && line.indent >= @orig_indent }
154
154
  end
155
155
 
156
+ def next_up
157
+ @code_lines[before_index.pred]
158
+ end
159
+
160
+ def next_down
161
+ @code_lines[after_index.next]
162
+ end
163
+
156
164
  def scan_adjacent_indent
157
- before_indent = @code_lines[@orig_before_index.pred]&.indent || 0
158
- after_indent = @code_lines[@orig_after_index.next]&.indent || 0
165
+ before_after_indent = []
166
+ before_after_indent << next_up&.indent || 0
167
+ before_after_indent << next_down&.indent || 0
159
168
 
160
- indent = [before_indent, after_indent].min
169
+ indent = before_after_indent.min
161
170
  self.scan_while {|line| line.not_empty? && line.indent >= indent }
162
171
 
163
172
  self
@@ -183,11 +192,11 @@ module DeadEnd
183
192
  end
184
193
 
185
194
  private def before_lines
186
- @code_lines[0...@orig_before_index]
195
+ @code_lines[0...@orig_before_index] || []
187
196
  end
188
197
 
189
198
  private def after_lines
190
- @code_lines[@orig_after_index.next..-1]
199
+ @code_lines[after_index.next..-1] || []
191
200
  end
192
201
  end
193
202
  end
@@ -143,7 +143,7 @@ module DeadEnd
143
143
  # Given that we know our syntax error exists somewhere in our frontier, we want to find
144
144
  # the smallest possible set of blocks that contain all the syntax errors
145
145
  def detect_invalid_blocks
146
- self.class.combination(@frontier).detect do |block_array|
146
+ self.class.combination(@frontier.select(&:invalid?)).detect do |block_array|
147
147
  holds_all_syntax_errors?(block_array)
148
148
  end || []
149
149
  end
@@ -37,9 +37,10 @@ module DeadEnd
37
37
  raise e
38
38
  end
39
39
 
40
- def self.call(source: , filename: , terminal: false, record_dir: nil, timeout: TIMEOUT_DEFAULT)
40
+ def self.call(source: , filename: , terminal: false, record_dir: nil, timeout: TIMEOUT_DEFAULT, io: $stderr)
41
41
  search = nil
42
42
  Timeout.timeout(timeout) do
43
+ record_dir ||= ENV["DEBUG"] ? "tmp" : nil
43
44
  search = CodeSearch.new(source, record_dir: record_dir).call
44
45
  end
45
46
 
@@ -50,10 +51,11 @@ module DeadEnd
50
51
  terminal: terminal,
51
52
  code_lines: search.code_lines,
52
53
  invalid_obj: invalid_type(source),
53
- io: $stderr
54
+ io: io
54
55
  ).call
55
- rescue Timeout::Error
56
- $stderr.puts "Search timed out DEAD_END_TIMEOUT=#{timeout}, run with DEBUG=1 for more info"
56
+ rescue Timeout::Error => e
57
+ io.puts "Search timed out DEAD_END_TIMEOUT=#{timeout}, run with DEBUG=1 for more info"
58
+ io.puts e.backtrace.first(3).join($/)
57
59
  end
58
60
 
59
61
  # Used for counting spaces
@@ -40,7 +40,7 @@ module DeadEnd
40
40
  .skip(:hidden?)
41
41
  .scan_while {|line| line.indent >= target_line.indent }
42
42
 
43
- neighbors = @code_lines[scan.before_index..scan.after_index]
43
+ neighbors = scan.code_block.lines
44
44
 
45
45
  until neighbors.empty?
46
46
  lines = [neighbors.pop]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeadEnd
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_end
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2020-12-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: When you get an "unexpected end" in your syntax this gem helps you find
14
14
  it
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.1.4
79
+ rubygems_version: 3.0.3
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Find syntax errors in your source in a snap