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

[Fix #1794] Check if there are tokens before accessing them #1795

Merged
merged 1 commit into from
Apr 20, 2015
Merged

[Fix #1794] Check if there are tokens before accessing them #1795

merged 1 commit into from
Apr 20, 2015

Conversation

schmijos
Copy link
Contributor

This PR fixes a problem occurring if rubocop scans empty files containing only new lines (#1794). I extracted the function determining the __END__ token into an own method which respects empty token lists.

I'm not sure what to expect from autocorrection though.

@schmijos schmijos changed the title fixes #1794: check if there are tokens before accessing them [Fix #1794]: check if there are tokens before accessing them Apr 14, 2015
@schmijos schmijos changed the title [Fix #1794]: check if there are tokens before accessing them [Fix #1794] Check if there are tokens before accessing them Apr 14, 2015
@jonas054
Copy link
Collaborator

You should expect autocorrect to give ['', ''].join("\n") for EnforcedStyle: final_newline and ['', '', ''].join("\n") for EnforcedStyle: final_blank_line, so please add those examples.

Could you also add an example for a file containing only newlines and __END__? I know it's a weird case, but it's possible so we should support it.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 16, 2015

Squash the commits into one and mention the bugfix in the changelog.

@schmijos
Copy link
Contributor Author

@bbatsov Do you know what's wrong with the build? Running bundle exec rspec && bundle exec rubocop on my local machine results in all green.

@jonas054
Copy link
Collaborator

The same error exists on master. It seems that the Documentation cop doesn't work with parser 2.2.2.0. You can reproduce the error locally if you run bundle update first.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 19, 2015

Rebase this on top of the current master.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 20, 2015

Ah, you'll need to rebase again unfortunately.

@schmijos
Copy link
Contributor Author

Ok, did it.

bbatsov added a commit that referenced this pull request Apr 20, 2015
[Fix #1794] Check if there are tokens before accessing them
@bbatsov bbatsov merged commit 2d957b0 into rubocop:master Apr 20, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 20, 2015

👍 Thanks!

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.

3 participants