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

Invalid autocorrect in Layout/SpaceInsideHashLiteralBraces #12736

Closed
bquorning opened this issue Mar 3, 2024 · 0 comments · Fixed by #12737
Closed

Invalid autocorrect in Layout/SpaceInsideHashLiteralBraces #12736

bquorning opened this issue Mar 3, 2024 · 0 comments · Fixed by #12737
Assignees
Labels

Comments

@bquorning
Copy link
Contributor

When letting Layout/SpaceInsideHashLiteralBraces autocorrect code containing the text '{' as the last value in a hash, invalid code will be generated.

Slightly related to #3958 and #3976.


Expected behavior

With EnforcedStyleForEmptyBraces: space, autocorrect

h = { a: '{'}

into

h = { a: '{' }

With EnforcedStyleForEmptyBraces: no_space, autocorrect

h = {a: '{' }

into

h = {a: '{'}

Actual behavior

With EnforcedStyleForEmptyBraces: space, autocorrects

h = { a: '{'}

into

h = { a:                                                                                                                                                                                                         '{'}

(with “Infinite loop detected”)

With EnforcedStyleForEmptyBraces: no_space, autocorrects

h = {a: '{' }

into

h = {a:' }

RuboCop version

$ ❯ be rubocop -V
1.61.0 (using Parser 3.3.0.5, rubocop-ast 1.31.1, running on ruby 3.3.0) [arm64-darwin22]
  - rubocop-performance 1.20.2
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.27.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant