Skip to content

Commit

Permalink
[Fix #11861] Fix a false positive for Layout/SpaceAfterSemicolon
Browse files Browse the repository at this point in the history
Fixes #11861.

This PR fixes a false positive for `Layout/SpaceAfterSemicolon`
when no space between a semicolon and a closing brace of string interpolation.
  • Loading branch information
koic authored and bbatsov committed May 9, 2023
1 parent b8005a4 commit 0bbce1a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11861](https://github.com/rubocop/rubocop/issues/11861): Fix a false positive for `Layout/SpaceAfterSemicolon` when no space between a semicolon and a closing brace of string interpolation. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/space_after_punctuation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def space_required_before?(token)
end

def allowed_type?(token)
%i[tRPAREN tRBRACK tPIPE].include?(token.type)
%i[tRPAREN tRBRACK tPIPE tSTRING_DEND].include?(token.type)
end

def space_forbidden_before_rcurly?
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/layout/space_after_semicolon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
it 'accepts a space between a semicolon and a closing brace' do
expect_no_offenses('test { ; }')
end

it 'accepts no space between a semicolon and a closing brace of string interpolation' do
expect_no_offenses(<<~'RUBY')
"#{ ;}"
RUBY
end
end

context 'when EnforcedStyle for SpaceInsideBlockBraces is space' do
Expand Down

0 comments on commit 0bbce1a

Please sign in to comment.