-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Enable unnecessary_null_checks lint #82084
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
Enable unnecessary_null_checks lint #82084
Conversation
Hello @goderbauer |
…cessary_null_checks_lint
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.
/cc @a14n I believe you attempted to enabled this before?
See #67443 I mentioned false positives in a comment but I don't exactly remember if I fixed them. |
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.
To make the CI happy you either have to disable the lint or add // ignore:...
comment on exceptions.
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.
LGTM
dev/snippets/lib/snippets.dart
Outdated
@@ -227,6 +227,7 @@ class SnippetGenerator { | |||
if (match != null) { // If we saw the start or end of a code block | |||
inCodeBlock = !inCodeBlock; | |||
if (match.namedGroup('language') != null) { | |||
// ignore: unnecessary_null_checks |
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.
I think this means the lint is not ready yet for our code base. We don't want these ignores everywhere.
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.
So should I comment the lint? @goderbauer
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.
Actually(after checking) the lint already handle self promotion to non-null (nullable = nullable!
is ok) and I think it would defeat the lint to allow any nullable = x!
.
A workaround to avoid // ignore
would be here:
language = match[1];
language = language!;
As there's only 2 cases where this happens I tend to see this workaround as acceptable.
dev/snippets/lib/snippets.dart
Outdated
@@ -227,6 +227,7 @@ class SnippetGenerator { | |||
if (match != null) { // If we saw the start or end of a code block | |||
inCodeBlock = !inCodeBlock; | |||
if (match.namedGroup('language') != null) { | |||
// ignore: unnecessary_null_checks |
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.
Actually(after checking) the lint already handle self promotion to non-null (nullable = nullable!
is ok) and I think it would defeat the lint to allow any nullable = x!
.
A workaround to avoid // ignore
would be here:
language = match[1];
language = language!;
As there's only 2 cases where this happens I tend to see this workaround as acceptable.
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.
LGTM
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.
LGTM
@Abhishek01039 could you rebase/push to trigger another build? Some current jobs seem to be stuck. |
…cessary_null_checks_lint
All test passed now! |
Enable unnecessary_null_checks lint
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.