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: #6668] Fix autocorrect for UnneededCondition with unless #6693

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Jan 22, 2019

Autocorrection of Style/UnneededCondition was broken for the unless case. This change adds tests for it and ensures the condition is put first in the resulting expression. See #6668 for more details.


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.

@@ -96,8 +96,9 @@ def else_source(else_branch)
end

def make_ternary_form(node)
ternary_form = [node.if_branch.source,
else_source(node.else_branch)].join(' || ')
_condition, if_branch, else_branch = *node
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at this change makes me think something is awry with the node extension for IfNode ... 🤔

@Drenmi
Copy link
Collaborator

Drenmi commented Jan 23, 2019

Sorry @mvz, there's a merge conflict in CHANGELOG. Please rebase on master, and I'll get this merged. 🙇

@mvz mvz force-pushed the issue-6668-fix-unneeded-condition-autocorrect-with-unless branch from 5160888 to c85e485 Compare January 23, 2019 08:23
@mvz
Copy link
Contributor Author

mvz commented Jan 23, 2019

@Drenmi done, thanks!

@Drenmi Drenmi merged commit 70ba0ad into rubocop:master Jan 23, 2019
@mvz mvz deleted the issue-6668-fix-unneeded-condition-autocorrect-with-unless branch January 23, 2019 15:19
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.

None yet

3 participants