Skip to content

Fix IfNode#branches to return both branches when called on ternary conditional#146

Merged
marcandre merged 1 commit intorubocop:masterfrom
fatkodima:if_node-branches-ternary
Nov 4, 2020
Merged

Fix IfNode#branches to return both branches when called on ternary conditional#146
marcandre merged 1 commit intorubocop:masterfrom
fatkodima:if_node-branches-ternary

Conversation

@fatkodima
Copy link
Copy Markdown
Contributor

Currently, it is returning only 1 branch.

@marcandre marcandre merged commit 94a8f87 into rubocop:master Nov 4, 2020
@marcandre
Copy link
Copy Markdown
Contributor

Good catch, thanks.

Expect a release later today.

let(:source) { 'foo? ? :foo : 42' }

it { expect(if_node.branches.size).to eq(2) }
it { expect(if_node.branches).to all(be_literal) }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI, I think you can do both in a single expectaction to match [be_literal, be_literal]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just stick to the existing codestyle and replicated the nearest similar example 😄

@marcandre
Copy link
Copy Markdown
Contributor

Oh, didn't notice, but the Changelog entry was misplaced.

Best use rake changelog:... in the future!

@marcandre
Copy link
Copy Markdown
Contributor

Released 1.1.1, thanks!

@fatkodima
Copy link
Copy Markdown
Contributor Author

I do not understand, how I did not noticed that it is not under master? It is the second time, at least, that I remember. 💦

@marcandre
Copy link
Copy Markdown
Contributor

I do not understand, how I did not noticed that it is not under master? It is the second time, at least, that I remember. 💦

You're probably too used to rubocop with a gazillion things in the "current" section

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.

2 participants