Skip to content

Commit

Permalink
[Fix #7509] Layout/SpaceInsideArrayLiteralBrackets to correct empty l…
Browse files Browse the repository at this point in the history
…ines
  • Loading branch information
ayacai115 committed Nov 17, 2019
1 parent 397043d commit 7b0fbc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/rubocop/cop/correctors/space_corrector.rb
Expand Up @@ -12,12 +12,11 @@ class << self
def empty_corrections(processed_source, corrector, empty_config,
left_token, right_token)
@processed_source = processed_source
range = range_between(left_token.end_pos, right_token.begin_pos)
if offending_empty_space?(empty_config, left_token, right_token)
range = side_space_range(range: left_token.pos, side: :right)
corrector.remove(range)
corrector.insert_after(left_token.pos, ' ')
elsif offending_empty_no_space?(empty_config, left_token, right_token)
range = side_space_range(range: left_token.pos, side: :right)
corrector.remove(range)
end
end
Expand Down
Expand Up @@ -42,6 +42,11 @@
new_source = autocorrect_source('a = [ ]')
expect(new_source).to eq('a = []')
end

it 'auto-corrects multiline spaces' do
new_source = autocorrect_source("a = [\n]")
expect(new_source).to eq('a = []')
end
end

context 'with space inside empty braces allowed' do
Expand Down

0 comments on commit 7b0fbc6

Please sign in to comment.