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

Comment gets eaten by autofixer #2848

Closed
ptarjan opened this issue Feb 15, 2016 · 1 comment · Fixed by #2873
Closed

Comment gets eaten by autofixer #2848

ptarjan opened this issue Feb 15, 2016 · 1 comment · Fixed by #2873

Comments

@ptarjan
Copy link
Contributor

ptarjan commented Feb 15, 2016

I'm not sure which autofixer did it, but here was my starting code:

[a, # a
 b # b
]

And here are all the autofixers that ran:

$ rubocop -D -a a.rb
Inspecting 1 file
C

Offenses:

a.rb:1:1: C: [Corrected] Style/MultilineArrayBraceLayout: Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
[
^
a.rb:1:1: C: [Corrected] Style/MultilineArrayBraceLayout: Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.
[a, # a
^^^^^^^
a.rb:1:2: C: [Corrected] Style/FirstArrayElementLineBreak: Add a line break before the first element of a multi-line array.
[a, # a
 ^
a.rb:2:1: C: [Corrected] Style/IndentArray: Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
a, # a
^
a.rb:3:1: C: [Corrected] Style/AlignArray: Align the elements of an array literal if they span more than one line.
b
^
a.rb:3:1: C: [Corrected] Style/TrailingCommaInLiteral: Put a comma after the last item of a multiline array.
b
^
a.rb:3:2: C: [Corrected] Style/AlignArray: Align the elements of an array literal if they span more than one line.
 b]
 ^

1 file inspected, 7 offenses detected, 7 offenses corrected

And it ended up with

[
  a, # a
  b,
]
@alexdowad
Copy link
Contributor

@jonas054 You are fixing this one?

jonas054 added a commit to jonas054/rubocop that referenced this issue Feb 22, 2016
…o-correct

Instead of removing the range preceding the ), which can contain
a heredoc, remove the ) and insert another one in the correct place.

Also fixes rubocop#2848 where it's comments instead of heredocs and ]
instead of ) but the principle is the same.
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 a pull request may close this issue.

2 participants