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

MultilineMethodCallBraceLayout with new_line style false positive #3462

Closed
maxjacobson opened this issue Aug 31, 2016 · 0 comments
Closed

MultilineMethodCallBraceLayout with new_line style false positive #3462

maxjacobson opened this issue Aug 31, 2016 · 0 comments
Labels

Comments

@maxjacobson
Copy link
Contributor

I believe the following is a false positive offense in this cop when it's configured this way:

Expected behavior

My .rubocop.yml:

MultilineMethodCallBraceLayout:
  EnforcedStyle: new_line

My ruby:

feed(
  'dog food', [
    dog1,
    dog2
  ].join(' ')
)

Expect no offenses

Actual behavior

$ rubocop -D
Inspecting 1 file
C

Offenses:

indent.rb:5:13: C: Style/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument.
  ].join(' ')
            ^

1 file inspected, 1 offense detected

Workaround

I can satisfy the cop by changing my ruby to this:

feed(
  'dog food', [
    dog1,
    dog2
  ].join(
    ' '
  )
)

But I don't think it should be necessary, because the join method call is not multiline

Steps to reproduce the problem

Using the above yaml and ruby code and running rubocop should reproduce the same behavior

RuboCop version

Include the output of rubocop -V:

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-darwin14)
@bbatsov bbatsov added the bug label Sep 7, 2016
mikezter added a commit to mikezter/rubocop that referenced this issue Sep 28, 2016
* bbatsov/master: (80 commits)
  [Fix rubocop#3540] Make `Style/GuardClause` register offense for instance & singleton methods
  [Fix rubocop#3436] issue related to Rails/SaveBang when returning non-bang call from the parent method
  Allow `#to_yml` to produce single-quoted strings
  Add support for StyleGuideBaseURL and update rules
  Add spec for the existing style guide URL implementation
  Fix the changelog
  Edited regular expression for normal case to fix issues rubocop#3514 and rubocop#3516 (rubocop#3524)
  Add a rake task for generation a new cop (rubocop#3533)
  [Fix rubocop#3510] Various bug fixes for SafeNavigation (rubocop#3517)
  [Fix rubocop#3512] Change error message of `Lint/UnneededSplatExpansion` for array (rubocop#3526)
  Fix false positive in `Lint/AssignmentInCondition` (rubocop#3520) (rubocop#3529)
  Rename a mismatched filename (rubocop#3523)
  Fix a broken changelog entry
  [Fix rubocop#3511] Style/TernaryParentheses false positive (rubocop#3513)
  Fix the release notes for 0.43
  Cut 0.43.0
  [Fix rubocop#3462] Don't flag single-line methods
  Fix false negatives in `Rails/NotNullColumn` cop (rubocop#3508)
  Remove unused doubled methods (rubocop#3509)
  [Fix rubocop#3485] Make OneLineConditional cop ignore empty else (rubocop#3487)
  ...
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
The idea is that we can still consider a method call "single line" even
when the receiver spans multiple lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants