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

Keep line breaks in place on WordArray autocorrect #2071

Merged

Conversation

unmanbearpig
Copy link
Contributor

I've found a problem that when I have an array of words that spans
multiple lines

array = ['first_word', 'second_word', 'third_word', 'fourth_word',
         'fifth_word', 'sixth_word', 'seveth_word']

Auto-correct replaces it with %w() syntax, which is fine, but it also
removes all of the line breaks, which makes the line too long and forces
me to fix it manually.

I've made Syntax/WordArray take into account existing line breaks when
it auto-corrects it.

@@ -59,9 +59,21 @@ def word_regex
cop_config['WordRegex']
end

def autocorrect_words(word_nodes, base_line_number)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to make all calls downwards in the file. Put this method after autocorrect.

@unmanbearpig unmanbearpig force-pushed the style-word-array-line-breaks-fix branch from d216553 to babd2a0 Compare July 26, 2015 15:18
I've found a problem that when I have an array of words that spans
multiple lines

```ruby
array = ['first_word', 'second_word', 'third_word', 'fourth_word',
         'fifth_word', 'sixth_word', 'seveth_word']
```

Autocorrect replaces it with %w() syntax, which is fine, but it also
removes all of the line breaks, which makes the line too long and forces
me to fix it manually.

I've made Syntax/WordArray take into account existing line breaks when
it autocorrects it.
@unmanbearpig unmanbearpig force-pushed the style-word-array-line-breaks-fix branch from babd2a0 to 3c8979a Compare July 26, 2015 15:22
@unmanbearpig
Copy link
Contributor Author

Thanks for feedback, I've fixed it and added a note to the changelog.

bbatsov added a commit that referenced this pull request Jul 26, 2015
…ks-fix

Keep line breaks in place on WordArray autocorrect
@bbatsov bbatsov merged commit b080b1a into rubocop:master Jul 26, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 26, 2015

👍 Looks good. 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