Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand search for both unexpected end-of-input as well as unexpected end #8

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

schneems
Copy link
Collaborator

@schneems schneems commented Nov 11, 2020

I'm not sure why the tests didn't catch this:

  /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb:18: syntax error, unexpected end-of-input, expecting `end'

It seems circle's error message is different for some reason:

/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': /tmp/d20201111-79-lhlcok/script.rb:10: syntax error, unexpected `end', expecting end-of-input (SyntaxError)
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /home/circleci/project/lib/syntax_search/auto.rb:26:in `require_relative'
	from /tmp/d20201111-79-lhlcok/require.rb:1:in `<main>'
/tmp/d20201111-79-lhlcok/script.rb:10: syntax error, unexpected `end', expecting end-of-input

https://app.circleci.com/pipelines/github/zombocom/syntax_search/28/workflows/8bb184c9-7f04-49ef-8d01-12c0cbc1a810

@schneems schneems force-pushed the schneems/error-match branch 3 times, most recently from e65f3e4 to 4646188 Compare November 11, 2020 16:28
I'm not sure why the tests didn't catch this:

```
  /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb:18: syntax error, unexpected end-of-input, expecting `end'
```

It seems circle's error message is different for some reason:

```
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': /tmp/d20201111-79-lhlcok/script.rb:10: syntax error, unexpected `end', expecting end-of-input (SyntaxError)
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /home/circleci/project/lib/syntax_search/auto.rb:26:in `require_relative'
	from /tmp/d20201111-79-lhlcok/require.rb:1:in `<main>'
/tmp/d20201111-79-lhlcok/script.rb:10: syntax error, unexpected `end', expecting end-of-input
```

https://app.circleci.com/pipelines/github/zombocom/syntax_search/28/workflows/8bb184c9-7f04-49ef-8d01-12c0cbc1a810
@schneems schneems merged commit d9673a9 into main Nov 11, 2020
@schneems
Copy link
Collaborator Author

The reason that wasn't caught is because it's a different error message. Removing an end produces an "unexpected end-of-input" versus removing a do produces an "unexpected end"

Missing do

         1  # frozen_string_literal: true
         2
         3  require_relative "../spec_helper.rb"
         4
         5  module HerokuBuildpackRuby
         6    RSpec.describe "toml" do
      ❯  7      it "parses toml correctly"
      ❯ 17      end
        18    end
        19  end




    An error occurred while loading ./spec/unit/toml_spec.rb.
    Failure/Error: Kernel.load(path, wrap)

    SyntaxError:
      /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb:19: syntax error, unexpected `end', expecting end-of-input
    # /Users/rschneeman/.gem/ruby/2.7.1/gems/syntax_search-0.1.1/lib/syntax_search/auto.rb:40:in `load'

Missing end:

file: /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb
simplified:

     1  # frozen_string_literal: true
     2
     3  require_relative "../spec_helper.rb"
     4
     5  module HerokuBuildpackRuby
     6    RSpec.describe "toml" do
  ❯  7      it "parses toml correctly" do
    17    end
    18  end





An error occurred while loading ./spec/unit/toml_spec.rb.
Failure/Error: Kernel.load(path, wrap)

SyntaxError:
  /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb:18: syntax error, unexpected end-of-input, expecting `end'
# /Users/rschneeman/.gem/ruby/2.7.1/gems/syntax_search-0.1.1/lib/syntax_search/auto.rb:40:in `load'

Fin

It turns out that the same search looks helpful for both cases so it's fine to expand the scope of the gem.

@schneems schneems deleted the schneems/error-match branch November 11, 2020 16:38
@schneems schneems changed the title Schneems/error match Expand search for both unexpected end-of-input as well as unexpected end Nov 11, 2020
schneems added a commit that referenced this pull request Nov 12, 2020
As mentioned in #8 (comment) there are two types of syntax errors that can be hit involving an end:

- It's got and end but wasn't expecting one (unmatched end)
- It needs an end but doesn't have one (missing end)

To make this more clear, the output of SyntaxSearch now specializes for these two cases and gives a helpful output with more context.
schneems added a commit that referenced this pull request Nov 12, 2020
As mentioned in #8 (comment) there are two types of syntax errors that can be hit involving an end:

- It's got and end but wasn't expecting one (unmatched end)
- It needs an end but doesn't have one (missing end)

To make this more clear, the output of SyntaxSearch now specializes for these two cases and gives a helpful output with more context.
schneems added a commit that referenced this pull request Jan 15, 2022
# This is the 1st commit message:

Move queue logic and engulf logic to a class

The queuing and engulfing logic are tied together. We can bundle the two of them into a single class with a specific interface.
# This is the commit message #2:

WIP A*ish

# This is the commit message #3:

WIP with lex_diff OMG

# This is the commit message #4:

WIP Pull out "grab equal" logic of UpDownExpand

# This is the commit message #5:

WIP move class to proper file location

# This is the commit message #6:

WIP Fix spelling of method

# This is the commit message #7:

WIP LOL search

# This is the commit message #8:

Runs, finds the large code blocks, but is too greedy

# This is the commit message #9:

Move LexDiff to own class, refactor to an array

We're never using the hash keys so we don't need them. We can save memory and time by storing the values as an array.

# This is the commit message #10:

WIP LOL spec

# This is the commit message #11:

Micro optimize lex diff

# This is the commit message #12:

UpDownExpand fix major bug with internal mutability

When calling `line.lex_detect.dup` it was duplicating the outer memory, but not the inner memory. Internally we're using an array and the old array was still being referenced and mutated.

# This is the commit message #13:

LexDiff Huge perf upgrade

Store values in the object instead of an array.

# This is the commit message #14:

WIP playing with fuzzing this into the old algorithm

# This is the commit message #15:

WORKS and is hella fast

# This is the commit message #16:

WIP docs

# This is the commit message #17:

Put a max band on number of iterations

Unbounded while loops scare me, in theory this class should never iterate more than line times, but mistakes happen. When they do I want feedback for the user without disrupting the rest of their program.

# This is the commit message #18:

WIP Cleanup and docs

# This is the commit message #19:

WIP Cleanup and docs

# This is the commit message #20:

Standardrb

# This is the commit message #21:

Standardrb

# This is the commit message #22:

Refactor LexDiff, remove unused methods, add docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant