Skip to content

Commit

Permalink
Merge pull request #12376 from koic/fix_a_false_positive_for_layout_s…
Browse files Browse the repository at this point in the history
…pace_before_semicolon

[Fix #12374] Fix a false positive for `Layout/SpaceBeforeSemicolon`
  • Loading branch information
koic committed Nov 10, 2023
2 parents 80fce12 + 2a056d2 commit 95b0290
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12374](https://github.com/rubocop/rubocop/issues/12374): Fix a false positive for `Layout/SpaceBeforeSemicolon` when a space between an opening lambda brace and a semicolon. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/space_before_punctuation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def space_missing?(token1, token2)
end

def space_required_after?(token)
token.left_curly_brace? && space_required_after_lcurly?
(token.left_curly_brace? || token.type == :tLAMBEG) && space_required_after_lcurly?
end

def space_required_after_lcurly?
Expand Down
4 changes: 4 additions & 0 deletions spec/rubocop/cop/layout/space_before_semicolon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
it 'accepts a space between an opening brace and a semicolon' do
expect_no_offenses('test { ; }')
end

it 'accepts a space between an opening lambda brace and a semicolon' do
expect_no_offenses('-> { ; }')
end
end

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

0 comments on commit 95b0290

Please sign in to comment.