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

Layout/SpaceBeforeBrackets breaks code by removing brackets #9438

Closed
thorsteneckel opened this issue Jan 28, 2021 · 0 comments · Fixed by #9439
Closed

Layout/SpaceBeforeBrackets breaks code by removing brackets #9438

thorsteneckel opened this issue Jan 28, 2021 · 0 comments · Fixed by #9439
Labels

Comments

@thorsteneckel
Copy link

Running Layout/SpaceBeforeBrackets on the https://github.com/zammad/zammad codebase breaks code on various locations. It wrongly detects a space before brackets and then removed the bracket resulting in broken code. See example below.


Expected behavior

While the code is not nice (yet) at these locations it should pass IMHO or fix it correctly/not break the code.

Actual behavior

Breaks code by removing perfectly fine placed bracket.

Steps to reproduce the problem

Run rubocop -a on a file containing just this line:

collections[ Ticket::Article::Sender.to_app_model ] = []

Watch it to turn into:

collections Ticket::Article::Sender.to_app_model ] = []

Or for more:

cd /tmp
git clone https://github.com/zammad/zammad.git
cd zammad
rvm use 2.6.6
bundle
bundle update rubocop-performance rubocop-rails rubocop-rspec rubocop
bundle exec rubocop app/controllers/sessions/collection_base.rb
# or: bundle exec rubocop --parallel --only Layout/SpaceBeforeBrackets

RuboCop version

$ [bundle exec] rubocop -V
1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.6 x86_64-darwin19)
  - rubocop-performance 1.9.2
  - rubocop-rails 2.9.1
  - rubocop-rspec 2.1.0
@koic koic added the bug label Jan 28, 2021
koic added a commit to koic/rubocop that referenced this issue Jan 28, 2021
Fixes rubocop#9438

This PR fixes a false positive for `Layout/SpaceBeforeBrackets`
when space is used in left bracket.
bbatsov pushed a commit that referenced this issue Jan 28, 2021
Fixes #9438

This PR fixes a false positive for `Layout/SpaceBeforeBrackets`
when space is used in left bracket.
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.

2 participants