-
Notifications
You must be signed in to change notification settings - Fork 170
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
add use_if_null_to_convert_null_to_bool #2480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to catch cases where the operands are reversed (true == e
)?
Do we want to catch uses of !=
(e != false
)?
I don't want to bother yoda conditions lovers :) (this could be another lint BTW -
I will add some code to catch that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming to use_if_null_to_convert_nulls_to_bools
?
I feel like we've mostly pluralized. For example:
use_key_in_widget_constructors
use_late_for_private_fields_and_variables
use_setters_to_change_properties
etc.
|
||
import '../analyzer.dart'; | ||
|
||
const _desc = r'Use if-null operator to convert null to bool.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=>
'Use if-null operators to convert nulls to bools.';
(We standardized on plurals -- mostly 😬 )
|
||
const _details = r''' | ||
|
||
Use if-null operator to convert null to bool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=>
Use if-null operators to convert nulls to bools.
PS: this is super awesome! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Thanks! |
Description
Use if-null operator to convert null to bool.
BAD:
GOOD:
Fixes #2460