-
Notifications
You must be signed in to change notification settings - Fork 166
add use_if_null_to_convert_null_to_bool #2480
add use_if_null_to_convert_null_to_bool #2480
Conversation
bwilkerson
left a comment
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. |
pq
left a comment
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! |
pq
left a comment
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 dart-lang/sdk#58324