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

Does not handle missing newline between codeblocks gracefully #22

Closed
schneems opened this issue Dec 3, 2020 · 0 comments
Closed

Does not handle missing newline between codeblocks gracefully #22

schneems opened this issue Dec 3, 2020 · 0 comments

Comments

@schneems
Copy link
Collaborator

schneems commented Dec 3, 2020

context "timezones workaround" do
  it "should receive a time in UTC format and return the time with the"\
    "office's UTC offset substracted from it" do
    travel_to DateTime.new(2020, 10, 1, 10, 0, 0) do
    end
  end
end
context "test" do
  it "should" do
end

Produces:

❯ 1  context "timezones workaround" do
❯ 6  end
❯ 7  context "test" do
❯ 8    it "should" do
❯ 9  end

Which is far too aggressive. The reason is that there's no linebreak above line 7.

schneems added a commit that referenced this issue Dec 4, 2020
CodeLines are now lexically aware of keywords. This is used by the AroundBlockScan to allow stopping after a keyword has been hit.

In addition to stripping heredocs before searching, the CodeSearch now also strips lines that contain only comments. The combination of stripping heredocs and comments prevents false positives from lexing individual lines (since a comment might contain valid code i.e. `# def foo; end`. 

New APIs:

- CodeLine#is_comment?
- CodeLine#is_kw?
- CodeLine#is_end?
- AroundBlockScan.stop_after_kw
- AroundBlockScan.scan_neighbors
schneems added a commit that referenced this issue Dec 4, 2020
[Close #22] Lines are lexically aware of keywords
schneems added a commit that referenced this issue Dec 16, 2020
CodeLines are now lexically aware of keywords. This is used by the AroundBlockScan to allow stopping after a keyword has been hit.

In addition to stripping heredocs before searching, the CodeSearch now also strips lines that contain only comments. The combination of stripping heredocs and comments prevents false positives from lexing individual lines (since a comment might contain valid code i.e. `# def foo; end`.

New APIs:

- CodeLine#is_comment?
- CodeLine#is_kw?
- CodeLine#is_end?
- AroundBlockScan.stop_after_kw
- AroundBlockScan.scan_neighbors
schneems added a commit that referenced this issue 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

No branches or pull requests

1 participant