Skip to content

Conversation

@schneems
Copy link
Collaborator

@schneems schneems commented Oct 8, 2021

Described in #32 we are capturing the correct code blocks, however if the problem is mis-matched keyword, then the internals of the block are incorrectly hidden.

Code was added to work backwards and show that extra mis-matched keyword, unfortunately it grabbed more and caused a less-than-ideal output:

Before:

$ dead_end spec/fixtures/derailed_require_tree.rb.txt

DeadEnd: Missing `end` detected

This code has a missing `end`. Ensure that all
syntax keywords (`def`, `do`, etc.) have a matching `end`.

file: /Users/rschneeman/Documents/projects/dead_end/spec/fixtures/derailed_require_tree.rb.txt
simplified:

       5  module DerailedBenchmarks
       6    class RequireTree
       7      REQUIRED_BY = {}
       9      attr_reader   :name
      10      attr_writer   :cost
      11      attr_accessor :parent
    ❯ 13      def initialize(name)
    ❯ 27      def <<(tree)
    ❯ 31      end
    ❯ 33      def [](name)
    ❯ 35      end
    ❯ 38      def children
    ❯ 40      end
    ❯ 42      def cost
    ❯ 44      end
    ❯ 47      def sorted_children
    ❯ 49      end
      73    end
      74  end

Instead of digging into the problem with the existing code, I re-wrote it from scratch. I've frankly got no idea why it was broken previously, but the prior code didn't make much sense. This new version is much simpler and with added comments, fairly straightforward.

After:

$ ./exe/dead_end spec/fixtures/derailed_require_tree.rb.txt

DeadEnd: Missing `end` detected

This code has a missing `end`. Ensure that all
syntax keywords (`def`, `do`, etc.) have a matching `end`.

file: /Users/rschneeman/Documents/projects/dead_end/spec/fixtures/derailed_require_tree.rb.txt
simplified:

       5  module DerailedBenchmarks
       6    class RequireTree
       7      REQUIRED_BY = {}
       9      attr_reader   :name
      10      attr_writer   :cost
      11      attr_accessor :parent
    ❯ 13      def initialize(name)
    ❯ 18      def self.reset!
    ❯ 25      end
      73    end
      74  end

Described in #32 we are capturing the correct code blocks, however if the problem is mis-matched keyword, then the internals of the block are incorrectly hidden.

Code was added to work backwards and show that extra mis-matched keyword, unfortunately it grabbed more and caused a less-than-ideal output:

Before:

```
$ dead_end spec/fixtures/derailed_require_tree.rb.txt

DeadEnd: Missing `end` detected

This code has a missing `end`. Ensure that all
syntax keywords (`def`, `do`, etc.) have a matching `end`.

file: /Users/rschneeman/Documents/projects/dead_end/spec/fixtures/derailed_require_tree.rb.txt
simplified:

       5  module DerailedBenchmarks
       6    class RequireTree
       7      REQUIRED_BY = {}
       9      attr_reader   :name
      10      attr_writer   :cost
      11      attr_accessor :parent
    ❯ 13      def initialize(name)
    ❯ 27      def <<(tree)
    ❯ 31      end
    ❯ 33      def [](name)
    ❯ 35      end
    ❯ 38      def children
    ❯ 40      end
    ❯ 42      def cost
    ❯ 44      end
    ❯ 47      def sorted_children
    ❯ 49      end
      73    end
      74  end
```

Instead of digging into the problem with the existing code, I re-wrote it from scratch. I've frankly got no idea why it was broken previously, but the prior code didn't make much sense. This new version is much simpler and with added comments, fairly straightforward.

After:

```
$ ./exe/dead_end spec/fixtures/derailed_require_tree.rb.txt

DeadEnd: Missing `end` detected

This code has a missing `end`. Ensure that all
syntax keywords (`def`, `do`, etc.) have a matching `end`.

file: /Users/rschneeman/Documents/projects/dead_end/spec/fixtures/derailed_require_tree.rb.txt
simplified:

       5  module DerailedBenchmarks
       6    class RequireTree
       7      REQUIRED_BY = {}
       9      attr_reader   :name
      10      attr_writer   :cost
      11      attr_accessor :parent
    ❯ 13      def initialize(name)
    ❯ 18      def self.reset!
    ❯ 25      end
      73    end
      74  end

```
@schneems schneems force-pushed the schneems/issues/50 branch from e4b2a76 to 62334dd Compare October 8, 2021 02:28
@schneems schneems merged commit 2890304 into main Oct 8, 2021
@schneems schneems deleted the schneems/issues/50 branch October 8, 2021 02:45
@schneems schneems mentioned this pull request Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants