Skip to content

avoid_bool_literals_in_conditional_expressions false positives #58067

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

Closed
davidmorgan opened this issue Nov 22, 2019 · 3 comments
Closed

avoid_bool_literals_in_conditional_expressions false positives #58067

davidmorgan opened this issue Nov 22, 2019 · 3 comments
Labels
customer-google3 devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-false-positive type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@davidmorgan
Copy link
Contributor

If either side of the conditional expression is nullable, the suggested replacement fails.

condition ? true : myNullableFunction()

cannot be replaced with

condition || myNullableFunction()

--we could tighten up the lint to only apply to expressions that we know are not nullable, or we could wait for NNBD which will allow the lint to still fire on more cases.

While I like this lint I don't think it's terribly urgent, so my suggestion is to wait for NNBD.

What do you think, please?

@bwilkerson
Copy link
Member

I agree that we should wait for NNBD. The analyzer currently has no way of determining whether an expression is nullable, so fixing it now would be difficult at best.

@davidmorgan
Copy link
Contributor Author

Well, there are expressions that must evaluate to either true or false, e.g.:

condition ? true : foo == bar

--and this seems to be more common than nullable expressions. So it would still be quite useful.

But changing it now just to change it again seems less good overall than awaiting for NNBD :)

Thanks.

@pq pq added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) customer-google3 linter-false-positive labels Nov 30, 2019
@srawlins
Copy link
Member

srawlins commented Sep 4, 2022

I'll close this in favor of null safety. If I've misunderstood, please re-open.

@srawlins srawlins closed this as completed Sep 4, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-google3 devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-false-positive type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants