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

enhancement: simplify a ? false : b #612

Closed
Spongman opened this issue Oct 18, 2019 · 3 comments
Closed

enhancement: simplify a ? false : b #612

Spongman opened this issue Oct 18, 2019 · 3 comments

Comments

@Spongman
Copy link

Product and Version Used: 2.2.0

Steps to Reproduce:

get refactorings for a ? false : b

Actual Behavior:
no simplification

Expected Behavior:
simplification: !a && b

@LesRamer
Copy link

Here's that expression and 3 more that I would also expect to simplify:

expression simplified
a ? false : b !a && b
a ? true : b a || b
a ? b : false a && b
a ? b : true !a || b

@wiz0u
Copy link

wiz0u commented Dec 11, 2019

Make sure b is bool, because these simplified expressions don't work if b is bool? for example

@josefpihrt
Copy link
Collaborator

josefpihrt commented Feb 3, 2020

@LesRamer 2nd and 3rd case is already covered by RCS1104. The other two ones are tricky because there is a negation which can lead to less readable code.

It would be useful to add refactoring (not analyzer) that would simplify these two remaining cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants