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 #7635] Fix a false positive for Style/MultilineWhenThen #7889

Merged

Conversation

koic
Copy link
Member

@koic koic commented Apr 18, 2020

Fixes #7635

This PR fixes a false positive for Style/MultilineWhenThen when then required for a body of when is used.


Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the fix_a_false_positive_for_multiline_when_then branch from ebf386b to 31d2388 Compare April 19, 2020 07:16
CHANGELOG.md Outdated
@@ -7,6 +7,7 @@
* [#7882](https://github.com/rubocop-hq/rubocop/pull/7882): Fix `Style/CaseEquality` when `AllowOnConstant` is `true` and the method receiver is implicit. ([@rafaelfranca][])
* [#7790](https://github.com/rubocop-hq/rubocop/issues/7790): Fix `--parallel` and `--ignore-parent-exclusion` combination. ([@jonas054][])
* [#7881](https://github.com/rubocop-hq/rubocop/issues/7881): Fix `--parallel` and `--force-default-config` combination. ([@jonas054][])
* [#7635](https://github.com/rubocop-hq/rubocop/issues/7635): Fix a false positive for `Style/MultilineWhenThen` when a `when` body has multiple lines with breakline. ([@koic][])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get "multiple lines with breakline". Don't you always have line breaks in something that's multiline?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... this is a strange sentence 💦 I updated the sentence to:
"when then required for a body of when is used."

@koic koic force-pushed the fix_a_false_positive_for_multiline_when_then branch from 31d2388 to f2daeed Compare April 19, 2020 08:20
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 19, 2020

I think it's also a good idea to mention this in the "good" examples in the cop's documentation, as technically it's a multi-line then, but not something the cop's concerned about.

Fixes rubocop#7635

This PR fixes a false positive for `Style/MultilineWhenThen`
when `then` required for a body of `when` is used.
@koic koic force-pushed the fix_a_false_positive_for_multiline_when_then branch from f2daeed to dbef91d Compare April 19, 2020 08:43
@koic
Copy link
Member Author

koic commented Apr 19, 2020

That idea seems reasonable 🌟 I added a good example for this case.

@bbatsov bbatsov merged commit 1de14f6 into rubocop:master Apr 20, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 20, 2020

Thanks!

@koic koic deleted the fix_a_false_positive_for_multiline_when_then branch April 20, 2020 04:37
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.

Style/MultilineWhenThen breaks some single line case statements
2 participants