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

add unnecessary_null_aware_operator_on_extension_on_nullable #3392

Conversation

a14n
Copy link
Contributor

@a14n a14n commented May 10, 2022

Following up on #3379 (comment) to add a warning when using null aware operator with a member defined in an extension on nullable type.

extension on String? {
  bool get isNullOrEmpty {
    var self = this;
    return self == null || self.isEmpty;
  }
}

main() {
  String? s = null;
  s?.isNullOrEmpty; // WARN here
  s.isNullOrEmpty; // OK
}

Migrated from dart-lang/sdk#48980 into linter

@coveralls
Copy link

coveralls commented May 10, 2022

Coverage Status

Coverage increased (+0.02%) to 95.656% when pulling 9ddb2d9 on a14n:unnecessary_null_aware_operator_on_extension_on_nullable into a3a265a on dart-lang:master.

@a14n a14n force-pushed the unnecessary_null_aware_operator_on_extension_on_nullable branch from 0423161 to 0093691 Compare May 10, 2022 21:07
Copy link
Member

@pq pq left a comment

Choose a reason for hiding this comment

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

💎

@pq pq merged commit e76b935 into dart-lang:master May 11, 2022
@a14n a14n deleted the unnecessary_null_aware_operator_on_extension_on_nullable branch May 12, 2022 05:58
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 23, 2023
…ng/linter#3392)

* add unnecessary_null_aware_operator_on_extension_on_nullable

* Address review comment
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.

4 participants