From 184552f12ffaf4537d3ef4f89a27bacc550f804f Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 6 Nov 2020 21:12:52 -0600 Subject: [PATCH 1/7] .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b04a8c8..98af4ab 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ # rspec failure tracking .rspec_status +.DS_Store + From 83e2e1cc8f27a1f688557a758c72171daa8e2f9c Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 13:52:50 -0600 Subject: [PATCH 2/7] Fix indentation space counting --- lib/syntax_error_search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/syntax_error_search.rb b/lib/syntax_error_search.rb index 943de76..efaa781 100644 --- a/lib/syntax_error_search.rb +++ b/lib/syntax_error_search.rb @@ -10,7 +10,7 @@ class Error < StandardError; end # Used for counting spaces module SpaceCount def self.indent(string) - string.split(/\w/).first&.length || 0 + string.split(/\S/).first&.length || 0 end end From 40b4d8024238d2d897c9c9bef972d3c96916a52a Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 13:53:12 -0600 Subject: [PATCH 3/7] Expose registering a codeblock to frontier When a block is added to the frontier, we remove it's lines from the indent_hash so that we do not accidentally re-create the same block multiple times. Previously this behavior was tied only to pushing a block to the frontier. This change exposes the behavior so that it can be invoked separately from pushing an object onto the frontier. Also when we generate a new block, we assume that it we don't want to re-generate the exact same block again (the method name is `next_block` after all) so we can go ahead and "register" it so we remove the appropriate lines from indent hash. This also allows us to generate blocks and evaluate them without having to put them back into the frontier without needing to worry about generating the same block again. --- lib/syntax_error_search/code_frontier.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/syntax_error_search/code_frontier.rb b/lib/syntax_error_search/code_frontier.rb index 1a23301..5474c20 100644 --- a/lib/syntax_error_search/code_frontier.rb +++ b/lib/syntax_error_search/code_frontier.rb @@ -185,10 +185,13 @@ def next_block indent = @indent_hash.keys.sort.last lines = @indent_hash[indent].first - CodeBlock.new( + block = CodeBlock.new( lines: lines, code_lines: @code_lines ).expand_until_neighbors + + register(block) + block end # This method is responsible for determining if a new code @@ -201,16 +204,21 @@ def generate_new_block? @frontier.last.current_indent <= @indent_hash.keys.sort.last end + def register(block) + block.lines.each do |line| + @indent_hash[line.indent]&.delete(line) + end + @indent_hash.select! {|k, v| !v.empty?} + self + end + # Add a block to the frontier # # This method ensures the frontier always remains sorted (in indentation order) # and that each code block's lines are removed from the indentation hash so we # don't re-evaluate the same line multiple times. def <<(block) - block.lines.each do |line| - @indent_hash[line.indent]&.delete(line) - end - @indent_hash.select! {|k, v| !v.empty?} + register(block) @frontier << block @frontier.sort! From 5f765d9e9f53d65647d7e2277ab254dc724392ef Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 14:06:24 -0600 Subject: [PATCH 4/7] Freeze all strings by default --- Gemfile | 2 ++ Rakefile | 2 ++ lib/syntax_error_search.rb | 2 ++ lib/syntax_error_search/code_block.rb | 2 ++ lib/syntax_error_search/code_frontier.rb | 2 ++ lib/syntax_error_search/code_line.rb | 2 ++ lib/syntax_error_search/code_search.rb | 2 ++ lib/syntax_error_search/display_invalid_blocks.rb | 2 ++ lib/syntax_error_search/version.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/syntax_error_search_spec.rb | 2 ++ spec/unit/code_block_spec.rb | 2 ++ spec/unit/code_frontier_spec.rb | 2 ++ spec/unit/code_line_spec.rb | 2 ++ spec/unit/code_search_spec.rb | 2 ++ syntax_error_search.gemspec | 2 ++ 16 files changed, 32 insertions(+) diff --git a/Gemfile b/Gemfile index cf46683..bb44deb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" # Specify your gem's dependencies in syntax_error_search.gemspec diff --git a/Rakefile b/Rakefile index b7e9ed5..ee617bb 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/gem_tasks" require "rspec/core/rake_task" diff --git a/lib/syntax_error_search.rb b/lib/syntax_error_search.rb index efaa781..6c7a7a3 100644 --- a/lib/syntax_error_search.rb +++ b/lib/syntax_error_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "syntax_error_search/version" require 'parser/current' diff --git a/lib/syntax_error_search/code_block.rb b/lib/syntax_error_search/code_block.rb index 98c1432..86386e1 100644 --- a/lib/syntax_error_search/code_block.rb +++ b/lib/syntax_error_search/code_block.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch # Multiple lines form a singular CodeBlock # diff --git a/lib/syntax_error_search/code_frontier.rb b/lib/syntax_error_search/code_frontier.rb index 5474c20..6921bfe 100644 --- a/lib/syntax_error_search/code_frontier.rb +++ b/lib/syntax_error_search/code_frontier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch # This class is responsible for generating, storing, and sorting code blocks # diff --git a/lib/syntax_error_search/code_line.rb b/lib/syntax_error_search/code_line.rb index d090cf8..8b6fa5e 100644 --- a/lib/syntax_error_search/code_line.rb +++ b/lib/syntax_error_search/code_line.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch # Represents a single line of code of a given source file # diff --git a/lib/syntax_error_search/code_search.rb b/lib/syntax_error_search/code_search.rb index 2f780f7..8dd0294 100644 --- a/lib/syntax_error_search/code_search.rb +++ b/lib/syntax_error_search/code_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch # Searches code for a syntax error # diff --git a/lib/syntax_error_search/display_invalid_blocks.rb b/lib/syntax_error_search/display_invalid_blocks.rb index e25b157..b462151 100644 --- a/lib/syntax_error_search/display_invalid_blocks.rb +++ b/lib/syntax_error_search/display_invalid_blocks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch # Used for formatting invalid blocks class DisplayInvalidBlocks diff --git a/lib/syntax_error_search/version.rb b/lib/syntax_error_search/version.rb index dfe477a..18b6e47 100644 --- a/lib/syntax_error_search/version.rb +++ b/lib/syntax_error_search/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch VERSION = "0.1.0" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 434a7cc..26ae3fe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/setup" require "syntax_error_search" diff --git a/spec/syntax_error_search_spec.rb b/spec/syntax_error_search_spec.rb index e4f29bc..64bb37d 100644 --- a/spec/syntax_error_search_spec.rb +++ b/spec/syntax_error_search_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SyntaxErrorSearch RSpec.describe SyntaxErrorSearch do it "has a version number" do diff --git a/spec/unit/code_block_spec.rb b/spec/unit/code_block_spec.rb index 7b0bf51..7fbbcc3 100644 --- a/spec/unit/code_block_spec.rb +++ b/spec/unit/code_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../spec_helper.rb" module SyntaxErrorSearch diff --git a/spec/unit/code_frontier_spec.rb b/spec/unit/code_frontier_spec.rb index 1f963a2..292308c 100644 --- a/spec/unit/code_frontier_spec.rb +++ b/spec/unit/code_frontier_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../spec_helper.rb" module SyntaxErrorSearch diff --git a/spec/unit/code_line_spec.rb b/spec/unit/code_line_spec.rb index 4dec437..5a82ed3 100644 --- a/spec/unit/code_line_spec.rb +++ b/spec/unit/code_line_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../spec_helper.rb" module SyntaxErrorSearch diff --git a/spec/unit/code_search_spec.rb b/spec/unit/code_search_spec.rb index 31796c0..2de9f0e 100644 --- a/spec/unit/code_search_spec.rb +++ b/spec/unit/code_search_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../spec_helper.rb" module SyntaxErrorSearch diff --git a/syntax_error_search.gemspec b/syntax_error_search.gemspec index c080c59..786e3a6 100644 --- a/syntax_error_search.gemspec +++ b/syntax_error_search.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'lib/syntax_error_search/version' Gem::Specification.new do |spec| From 5085f3ea0f791ff1aaf2b40d9442c46db00f3592 Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 14:15:43 -0600 Subject: [PATCH 5/7] Display Invalid Blocks improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Allow toggling the terminal characters on/off - Make indentation modular instead of being coupled to a specific method - Rename "code with filename" to "code_block" since it no longer includes the filename - Add a marker to invalid lines. Unicode arrow `❯` was chosen. It looks like this: ``` 1 module SyntaxErrorSearch 2 # Used for formatting invalid blocks 3 class DisplayInvalidBlocks ❯ 36 def filename ❯ 37 38 def code_with_filename 45 end 46 47 def code_with_lines 62 end 63 end 64 end ``` - Method argument changed from positional to kwargs for the block array --- .../display_invalid_blocks.rb | 45 ++++++--- spec/unit/code_search_spec.rb | 7 +- spec/unit/display_invalid_blocks_spec.rb | 96 +++++++++++++++++++ 3 files changed, 133 insertions(+), 15 deletions(-) create mode 100644 spec/unit/display_invalid_blocks_spec.rb diff --git a/lib/syntax_error_search/display_invalid_blocks.rb b/lib/syntax_error_search/display_invalid_blocks.rb index b462151..c329161 100644 --- a/lib/syntax_error_search/display_invalid_blocks.rb +++ b/lib/syntax_error_search/display_invalid_blocks.rb @@ -5,15 +5,16 @@ module SyntaxErrorSearch class DisplayInvalidBlocks attr_reader :filename - def initialize(block_array, io: $stderr, filename: nil) + def initialize(blocks:, io: $stderr, filename: nil, terminal: false) + @terminal = terminal @filename = filename @io = io - @blocks = block_array + @blocks = Array(blocks) @lines = @blocks.map(&:lines).flatten - @digit_count = @lines.last.line_number.to_s.length @code_lines = @blocks.first.code_lines + @digit_count = @code_lines.last.line_number.to_s.length - @invalid_line_hash = @lines.each_with_object({}) {|line, h| h[line] = true} + @invalid_line_hash = @lines.each_with_object({}) {|line, h| h[line] = true } end def call @@ -30,35 +31,53 @@ def call @io.puts <<~EOM simplified: - #{code_with_filename(indent: 2)} + #{indent(code_block)} EOM + self end + def indent(string, with: " ") + string.each_line.map {|l| with + l }.join + end - def code_with_filename(indent: 0) + def code_block string = String.new("") string << "```\n" # string << "#".rjust(@digit_count) + " filename: #{filename}\n\n" if filename string << code_with_lines string << "```\n" + string + end + + def terminal_end + "\e[0m" + end - string.each_line.map {|l| " " * indent + l }.join + def terminal_highlight + "\e[1;3m" # Bold, italics end def code_with_lines @code_lines.map do |line| next if line.hidden? + string = String.new("") + if @invalid_line_hash[line] + string << "❯ " + else + string << " " + end + number = line.line_number.to_s.rjust(@digit_count) + string << number.to_s if line.empty? - "#{number.to_s}#{line}" + string << line.to_s else - string = String.new - string << "\e[1;3m" if @invalid_line_hash[line] # Bold, italics - string << "#{number.to_s} " + string << " " + string << terminal_highlight if @terminal && @invalid_line_hash[line] # Bold, italics string << line.to_s - string << "\e[0m" - string + string << terminal_end if @terminal end + string end.join end end diff --git a/spec/unit/code_search_spec.rb b/spec/unit/code_search_spec.rb index 2de9f0e..5204e8c 100644 --- a/spec/unit/code_search_spec.rb +++ b/spec/unit/code_search_spec.rb @@ -34,7 +34,10 @@ def hai blocks = search.invalid_blocks io = StringIO.new - display = DisplayInvalidBlocks.new(blocks, io: io, filename: "fake/spec/lol.rb") + display = DisplayInvalidBlocks.new( + blocks: blocks, + io: io, + ) display.call puts io.string @@ -81,7 +84,7 @@ def hai blocks = search.invalid_blocks io = StringIO.new - display = DisplayInvalidBlocks.new(blocks, io: io, filename: "fake/spec/lol.rb") + display = DisplayInvalidBlocks.new(blocks: blocks, io: io, filename: "fake/spec/lol.rb") display.call # puts io.string diff --git a/spec/unit/display_invalid_blocks_spec.rb b/spec/unit/display_invalid_blocks_spec.rb new file mode 100644 index 0000000..868ada9 --- /dev/null +++ b/spec/unit/display_invalid_blocks_spec.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +require_relative "../spec_helper.rb" + +module SyntaxErrorSearch + RSpec.describe DisplayInvalidBlocks do + it "outputs to io when using `call`" do + code_lines = code_line_array(<<~EOM) + class OH + def hello + def hai + end + end + EOM + + io = StringIO.new + block = CodeBlock.new(code_lines: code_lines, lines: code_lines[1]) + display = DisplayInvalidBlocks.new( + blocks: block, + terminal: false, + io: io + ) + display.call + expect(io.string).to include("❯ 2 def hello") + expect(io.string).to include("A syntax error was detected") + end + + it " wraps code with github style codeblocks" do + code_lines = code_line_array(<<~EOM) + class OH + def hello + def hai + end + end + EOM + + block = CodeBlock.new(code_lines: code_lines, lines: code_lines[1]) + display = DisplayInvalidBlocks.new( + blocks: block, + terminal: false + ) + expect(display.code_block).to eq(<<~EOM) + ``` + 1 class OH + ❯ 2 def hello + 3 def hai + 4 end + 5 end + ``` + EOM + end + it "shows terminal characters" do + code_lines = code_line_array(<<~EOM) + class OH + def hello + def hai + end + end + EOM + + block = CodeBlock.new(code_lines: code_lines, lines: code_lines[1]) + display = DisplayInvalidBlocks.new( + blocks: block, + terminal: false + ) + + expect(display.code_with_lines).to eq( + [ + " 1 class OH", + "❯ 2 def hello", + " 3 def hai", + " 4 end", + " 5 end", + "" + ].join($/) + ) + + block = CodeBlock.new(code_lines: code_lines, lines: code_lines[1]) + display = DisplayInvalidBlocks.new( + blocks: block, + terminal: true + ) + + expect(display.code_with_lines).to eq( + [ + " 1 class OH", + ["❯ 2 ", display.terminal_highlight, " def hello"].join, + " 3 def hai", + " 4 end", + " 5 end", + "" + ].join($/ + display.terminal_end) + ) + end + end +end From f66163160898e555a4a8ffd14253d403be13230d Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 15:01:46 -0600 Subject: [PATCH 6/7] Record code search While debugging a code search it's very useful to see not just what is returned, but also the process through which that result was created. This commit adds that functionality as well as a test. In the process of writing this code, the internals of the search were refactored a bit also I found a bug where I was accidentally calling `expand_until_neighbors` when I meant to call `expand_until_next_boundry`. This broke a bunch of very brittle test cases --- lib/syntax_error_search/code_search.rb | 62 +++++++++++++++++++++----- spec/unit/code_search_spec.rb | 23 ++++++++++ 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/lib/syntax_error_search/code_search.rb b/lib/syntax_error_search/code_search.rb index 8dd0294..40d5f37 100644 --- a/lib/syntax_error_search/code_search.rb +++ b/lib/syntax_error_search/code_search.rb @@ -26,28 +26,66 @@ module SyntaxErrorSearch # class CodeSearch private; attr_reader :frontier; public - public; attr_reader :invalid_blocks + public; attr_reader :invalid_blocks, :record_dir - def initialize(string) + def initialize(string, record_dir: ENV["SYNTAX_SEARCH_RECORD_DIR"]) + if record_dir + @time = Time.now.strftime('%Y-%m-%d-%H-%M-%s-%N') + @record_dir = Pathname(record_dir).join(@time) + end @code_lines = string.lines.map.with_index do |line, i| CodeLine.new(line: line, index: i) end @frontier = CodeFrontier.new(code_lines: @code_lines) @invalid_blocks = [] + @name_tick = Hash.new {|hash, k| hash[k] = 0 } + @tick = 0 end - def call - until frontier.holds_all_syntax_errors? - frontier << frontier.next_block if frontier.next_block? + def record(block:, name: "record") + return if !@record_dir + @name_tick[name] += 1 + file = @record_dir.join("#{@tick}-#{name}-#{@name_tick[name]}.txt").tap {|p| p.dirname.mkpath } + file.open(mode: "a") do |f| + display = DisplayInvalidBlocks.new( + blocks: block, + terminal: false + ) + f.write(display.indent display.code_with_lines) + end + end + + def expand_frontier + return if !frontier.next_block? + block = frontier.next_block + record(block: block, name: "add") + if block.valid? + block.lines.each(&:mark_invisible) + return expand_frontier + else + frontier << block + end + block + end + + def search + expand_frontier - block = frontier.pop + block = frontier.pop - if block.valid? - block.lines.each(&:mark_invisible) - else - block.expand_until_neighbors - frontier << block - end + block.expand_until_next_boundry + record(block: block, name: "expand") + if block.valid? + block.lines.each(&:mark_invisible) + else + frontier << block + end + end + + def call + until frontier.holds_all_syntax_errors? + @tick += 1 + search end @invalid_blocks.concat(frontier.detect_invalid_blocks ) diff --git a/spec/unit/code_search_spec.rb b/spec/unit/code_search_spec.rb index 5204e8c..15f6335 100644 --- a/spec/unit/code_search_spec.rb +++ b/spec/unit/code_search_spec.rb @@ -4,6 +4,29 @@ module SyntaxErrorSearch RSpec.describe CodeSearch do + it "recording" do + Dir.mktmpdir do |dir| + dir = Pathname(dir) + search = CodeSearch.new(<<~EOM, record_dir: "tmp/recordings") + class OH + def hello + def hai + end + end + EOM + search.call + + expect(search.record_dir.entries.map(&:to_s)).to include("1-add-1.txt") + expect(search.record_dir.join("1-add-1.txt").read).to eq(<<~EOM.indent(2)) + 1 class OH + ❯ 2 def hello + ❯ 3 def hai + ❯ 4 end + 5 end + EOM + end + end + it "def with missing end" do search = CodeSearch.new(<<~EOM) class OH From 23ce3b5a3f9d4a52f3d6a084ce0f7394988f2964 Mon Sep 17 00:00:00 2001 From: schneems Date: Sun, 8 Nov 2020 20:02:26 -0600 Subject: [PATCH 7/7] Update tests --- lib/syntax_error_search/code_search.rb | 4 +- spec/unit/code_search_spec.rb | 88 ++++++++++++++++++++------ 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/lib/syntax_error_search/code_search.rb b/lib/syntax_error_search/code_search.rb index 40d5f37..23ce509 100644 --- a/lib/syntax_error_search/code_search.rb +++ b/lib/syntax_error_search/code_search.rb @@ -69,8 +69,6 @@ def expand_frontier end def search - expand_frontier - block = frontier.pop block.expand_until_next_boundry @@ -85,6 +83,8 @@ def search def call until frontier.holds_all_syntax_errors? @tick += 1 + expand_frontier + break if frontier.holds_all_syntax_errors? # Need to check after every time something is added to frontier search end diff --git a/spec/unit/code_search_spec.rb b/spec/unit/code_search_spec.rb index 15f6335..ce1c8f6 100644 --- a/spec/unit/code_search_spec.rb +++ b/spec/unit/code_search_spec.rb @@ -7,7 +7,7 @@ module SyntaxErrorSearch it "recording" do Dir.mktmpdir do |dir| dir = Pathname(dir) - search = CodeSearch.new(<<~EOM, record_dir: "tmp/recordings") + search = CodeSearch.new(<<~EOM, record_dir: dir) class OH def hello def hai @@ -28,6 +28,31 @@ def hai end it "def with missing end" do + search = CodeSearch.new(<<~EOM) + class OH + def hello + + def hai + puts "lol" + end + end + EOM + search.call + + expect(search.invalid_blocks.join.strip).to eq("def hello") + + search = CodeSearch.new(<<~EOM) + class OH + def hello + + def hai + end + end + EOM + search.call + + expect(search.invalid_blocks.join.strip).to eq("def hello") + search = CodeSearch.new(<<~EOM) class OH def hello @@ -48,10 +73,32 @@ def hai # These examples represent the results that exist today, but I would like to improve upon them describe "needs improvement" do describe "missing describe/do line" do + it "blerg" do + code_lines = code_line_array fixtures_dir.join("this_project_extra_def.rb.txt").read + block = CodeBlock.new( + lines: code_lines[27], + code_lines: code_lines + ) + expect(block.to_s).to eq(<<~EOM.indent(8)) + file: \#{filename} + EOM + + # puts block.before_line.to_s.inspect + # puts block.before_line.to_s.split(/\S/).inspect + # puts block.before_line.indent + + # puts block.after_line.to_s.inspect + # puts block.after_line.to_s.split(/\S/).inspect + # puts block.after_line.indent + + # puts block.next_indent + # puts block.expand_until_next_boundry + end it "this project" do - skip("Lol the results are really bad on this one") - search = CodeSearch.new(fixtures_dir.join("this_project_extra_def.rb.txt").read) + search = CodeSearch.new( + fixtures_dir.join("this_project_extra_def.rb.txt").read, + ) search.call @@ -62,10 +109,10 @@ def hai io: io, ) display.call - puts io.string + # puts io.string - expect(display.code_with_lines.strip_control_codes).to eq(<<~EOM) - 36 def filename + expect(display.code_with_lines.strip_control_codes).to include(<<~EOM) + ❯ 36 def filename EOM end @@ -112,13 +159,13 @@ def hai # puts io.string expect(display.code_with_lines.strip_control_codes).to eq(<<~EOM) - 1 require 'rails_helper' - 2 - 3 RSpec.describe AclassNameHere, type: :worker do - 4 describe "thing" do - 16 end # here - 30 end - 31 end + 1 require 'rails_helper' + 2 + 3 RSpec.describe AclassNameHere, type: :worker do + ❯ 4 describe "thing" do + ❯ 16 end # here + ❯ 30 end + 31 end EOM end end @@ -135,8 +182,8 @@ def foo EOM search.call - # Does not include the line with the error Foo.call expect(search.invalid_blocks.join).to eq(<<~EOM) + Foo.call def foo end end @@ -171,8 +218,8 @@ def foo EOM search.call - # Does not include the line with the error Foo.call expect(search.invalid_blocks.join).to eq(<<~EOM) + Foo.call end EOM end @@ -224,11 +271,14 @@ def foo EOM search.call - expect(search.invalid_blocks.join).to eq(<<~EOM.indent(2)) - Foo.call - end - Bar.call + expect(search.invalid_blocks.join).to eq(<<~EOM.indent(0)) + describe "hi" do + Foo.call + end end + + Bar.call + end EOM end