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

[Fix #9290] Fix a false positive for Layout/SpaceBeforeBrackets #9291

Conversation

koic
Copy link
Member

@koic koic commented Dec 25, 2020

Fixes #9290.

This PR fixes a false positive for Layout/SpaceBeforeBrackets when using array literal argument for method call.

If receiver is a method call, it is difficult to prevent false positives.
Therefore, This PR change behaviour to detect only when receiver is a variable.

As a result, safe detection is possible.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic koic force-pushed the fix_false_positive_for_layout_space_before_brackets branch 3 times, most recently from deb58e2 to dd773a0 Compare December 25, 2020 17:23
Fixes rubocop#9290.

This PR fixes a false positive for `Layout/SpaceBeforeBrackets`
when using array literal argument for method call.

If receiver is a method call, it is difficult to prevent false positives.
Therefore, This PR change behaviour to detect only when receiver is a variable.

As a result, safe detection is possible.
@koic koic force-pushed the fix_false_positive_for_layout_space_before_brackets branch from dd773a0 to 3dd743b Compare December 27, 2020 07:44
@bbatsov bbatsov merged commit 4114691 into rubocop:master Dec 27, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 27, 2020

Thanks!

@koic koic deleted the fix_false_positive_for_layout_space_before_brackets branch December 27, 2020 09:30
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Jan 9, 2021
This cop should work with RuboCop 1.8 which includes rubocop/rubocop#9291

```ruby
$ bundle exec rubocop -a
Inspecting 71 files
...........................C...........................................

Offenses:

lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:495:39: C: [Corrected] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
          @do_not_prefetch_primary_key [table_name] = do_not_prefetch = !has_primary_key?(table_name, owner, desc_table_name)
                                      ^

71 files inspected, 1 offense detected, 1 offense corrected

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rake (http://github.com/rubocop-hq/rubocop-rake)
  * rubocop-rspec (http://github.com/rubocop-hq/rubocop-rspec)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false
$
```
Refer rubocop/rubocop#9305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layout/SpaceBeforeBrackets: a space is incorrectly added to strip_whitespace % w[name email]
2 participants