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: false positive for arguments forwarding to Hash#[] #10573

Closed
yujideveloper opened this issue Apr 23, 2022 · 0 comments · Fixed by #10575
Closed

Layout/SpaceBeforeBrackets: false positive for arguments forwarding to Hash#[] #10573

yujideveloper opened this issue Apr 23, 2022 · 0 comments · Fixed by #10575
Labels

Comments

@yujideveloper
Copy link
Contributor

yujideveloper commented Apr 23, 2022

Expected behavior

It does not detect offense of Layout/SpaceBeforeBrackets.

Actual behavior

$ rubocop --debug --cache false --only Layout/SpaceBeforeBrackets foo.rb
For /Users/yuji_developer/foo: configuration from /Users/yuji_developer/foo/.rubocop.yml
Default configuration from /Users/yuji_developer/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/rubocop-1.28.1/config/default.yml
Inspecting 1 file
Scanning /Users/yuji_developer/foo/foo.rb
C

Offenses:

foo.rb:7:10: C: [Correctable] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
    @hash.[](...)
         ^

1 file inspected, 1 offense detected, 1 offense auto-correctable
Finished in 0.06047500018030405 seconds

Steps to reproduce the problem

Run rubocop --only Layout/SpaceBeforeBrackets foo.rb on the following config and code.

# .rubocop.yml
AllCops:
  TargetRubyVersion: 2.7
  NewCops: disable
# foo.rb
class Foo
  def initialize
    @hash = {}
  end

  def [](...)
    @hash.[](...)
  end
end

RuboCop version

$ rubocop -V
1.28.1 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 2.7.6 arm64-darwin21)
@yujideveloper yujideveloper changed the title Layout/SpaceBeforeBrackets false positive Layout/SpaceBeforeBrackets: false positive for arguments forwarding to Hash#[] Apr 23, 2022
@koic koic added the bug label Apr 23, 2022
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 23, 2022
…ets` when using desugared `Hash#[]` method
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 23, 2022
…ets` when using desugared `Hash#[]` method
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 23, 2022
…ets` when using desugared `Hash#[]` method
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 23, 2022
…ets` when there is a dot before bracket

Update lib/rubocop/cop/layout/space_before_brackets.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 24, 2022
…ets` when there is a dot before bracket

Update lib/rubocop/cop/layout/space_before_brackets.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>

Update lib/rubocop/cop/layout/space_before_brackets.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
koic added a commit that referenced this issue Apr 24, 2022
…pace-before-brackets-if-called-desugared-hash-brackets

[Fix #10573] Fix a false positive for `Layout/SpaceBeforeBrackets`
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